Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/310.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 调用函数find()beautifulsoup时,结果不完整_Python_Html_Python 3.x_Beautifulsoup_Web Crawler - Fatal编程技术网

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也不起作用