Python 调用函数find()beautifulsoup时,结果不完整
为了研究目的,我试图爬过这个,但我得到了一个不完整的结果:Python 调用函数find()beautifulsoup时,结果不完整,python,html,python-3.x,beautifulsoup,web-crawler,Python,Html,Python 3.x,Beautifulsoup,Web Crawler,为了研究目的,我试图爬过这个,但我得到了一个不完整的结果: opener = urllib.request.build_opener() opener.addheaders = [('User-Agent', 'Mozilla/5.0')] response = opener.open(url) soup = BeautifulSoup(response, 'html.parser') article = soup.find("div", { "class" : "entry" }) print
opener = urllib.request.build_opener()
opener.addheaders = [('User-Agent', 'Mozilla/5.0')]
response = opener.open(url)
soup = BeautifulSoup(response, 'html.parser')
article = soup.find("div", { "class" : "entry" })
print(article)
它给了我这个结果:
<div class="entry">
<header><strong>Racial Forensics in an Age of Race Denial</strong></header></div>
种族否认时代的种族取证
但当我查看页面的代码源时,我可以看到更多:
<div class="entry">
<header><strong>Racial Forensics in an Age of Race Denial</strong></p>
</header>
<p>Austen Layard<br/>
<a href="http://www.theoccidentalobserver.net/2014/01/racial-forensics-in-an-age-of-race-denial/"><strong>Occidental Observer</strong></a><br/>
February 3, 2014</p>
....
</div>
种族否认时代的种族取证
奥斯汀·莱亚德
2014年2月3日
....
这个URL与我处理过的许多其他URL之间的区别在于标签标题的存在
那是我问题的根源吗?
如何检索标记div
的全部内容
soup = BeautifulSoup(response, 'lxml')
html.parser
不稳定且高度不推荐,默认情况下,bs4使用lxml
,让我们保持默认设置。@MYGz也不起作用