我想用BeautifulSoup遍历一个HTML文件,找到内容为“Preferred Name”的标记 下面是我要查找的标签:(这是我要搜索的文件的一部分):
<td nowrap class="label">
Preferred Name
<span class="slot_labels"></span>
</td>
我试图用这个搜索(doc是该html文件的名称):
soup = BeautifulSoup(doc)
tags = soup.fetch('td')
for tag in tags:
if tag.contents[0] == 'Preferred Name':
return tag
这个代码不起作用,有人能帮忙吗。。。?你知道吗
内容包含空格,请尝试以下操作:
相关问题 更多 >
编程相关推荐