【发布时间】:2013-10-06 21:59:47
【问题描述】:
您好,我有如下回复
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<person>
<first-name>hede</first-name>
<last-name>hodo</last-name>
<headline>Python Developer at hede</headline>
<site-standard-profile-request>
<url>http://www.linkedin.com/profile/view?id=hede&authType=godasd*</url>
</site-standard-profile-request>
</person>
我想解析从linkedin api返回的内容。
我正在使用如下所示的美丽汤
ipdb> hede = BeautifulSoup(response.content)
ipdb> hede.person.headline
<headline>Python Developer at hede</headline>
但是当我这样做时
ipdb> hede.person.first-name
*** NameError: name 'name' is not defined
有什么想法吗?
【问题讨论】:
-
BeautifulSoup 是一个 HTML 解析器,为此任务使用一个实际的 XML 解析器。
标签: python xml beautifulsoup