【发布时间】:2014-12-12 02:05:19
【问题描述】:
我正在 facebook 的 html 页面中搜索名称。 如果我像这样获取文件 html.txt:
html = open('html.txt','r').read()
soup = BeautifulSoup(html)
如果我用 find 搜索名字似乎没问题,但如果我尝试用 BS 搜索我什么都找不到..
>>>html.find("Joseph Tan")
98939
>>>html[98700:99000]
'<div class="fwn fcg"><span class="fcg"><span class="fwb"><a class="profileLink" href="https://www.facebook.com/ASD.391" data-ft="{"tn":"l"}" data-hovercard="/ajax/hovercard/user.php?id=123456">Alex Tan</a></span> condivided the photo <a class="profileLink" '
>>> soup.findAll('div',{'class':'fwn fcg'})
[]
>>> soup.findAll('span',{'class':'fwb'})
[]
>>> soup.findAll('a',{'class':'profileLink'})
[]
>>>
有人可以帮助我吗?非常感谢
编辑:重新创建的 HTML 页面
【问题讨论】:
-
你能分享示例 HTML 代码吗?
-
我重新创建了 html 页面并更正了名称。我在等你的帮助
标签: parsing python-2.7 beautifulsoup