码迷,mamicode.com
首页 > 编程语言 > 详细

《python 网络数据采集》代码更新

时间:2018-04-10 15:27:15      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:virt   port   different   this   pen   urlopen   system   parse   available   

《python 网络数据采集》这本书中会出现很多这一段代码:

1 from urllib.request import urlopen
2 from bs4 import BeautifulSoup
3 html = urlopen(url)
4 bsobj = BeautifulSoup(html)

我也跟着输入这一段代码,但会出现提示:

UserWarning: No parser was explicitly specified, so I‘m using the best available HTML parser for this system ("html.parser"). This usually isn‘t a problem, but if you run this code on another system, or in a different virtual environment, it may use a different parser and behave differently.

The code that caused this warning is on line 1 of the file <string>. To get rid of this warning, change code that looks like this:

BeautifulSoup(YOUR_MARKUP})

to this:

BeautifulSoup(YOUR_MARKUP, "html.parser")

根据提示,这要把 bsobj = BeautifulSoup(html),改为bsobj = BeautifulSoup(html,"html.parser")就行了。

《python 网络数据采集》代码更新

标签:virt   port   different   this   pen   urlopen   system   parse   available   

原文地址:https://www.cnblogs.com/sineik/p/8778387.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!