python爬虫之BeautifulSoup初始运行时警告

 时间:2024-10-12 14:04:09

1、Python在进行网页爬虫时,代码如下:from urllib.request import urlopen from bs4 import BeautifulSoup html = urlopen("http://www.pythonscraping.com/pages/page1.html") bsObj = BeautifulSoup(html) print (bsObj.h1) nameList = bsObj.findAll(text='the prince') print(len(nameList))

python爬虫之BeautifulSoup初始运行时警告

3、紧接着是因此此警告的原因,初始化时,未加上解析器亿姣灵秀类型The code that caused this warning is on line 4 of the file C:/Users/15057/PycharmProjects/Stock/Stockinvest/test.py. To get rid of this warning, change code that looks like this:BeautifulSoup(YOUR_MARKUP})to this:BeautifulSoup(YOUR_MARKUP, "lxml") markup_type=markup_type)

python爬虫之BeautifulSoup初始运行时警告

5、将代码bsObj = BeautifulSoup(html.read())改为bsObj = BeautifulSoup(html.read(),"lxml")就不会报错了

python爬虫之BeautifulSoup初始运行时警告
  • 如何创建一个win32 HelloWorld入门程序
  • 如何在VS2013中新建WindowsService定时任务
  • VS2019如何在Basic显示错误
  • 如何让Qt串口发送ASCII
  • 热门搜索
    气球怎么做花样 qq邮箱怎么写 芒果怎么切 etc怎么充值 薄饼的做法大全 牙菌斑怎么去除 圆白菜怎么做好吃 孕妇拉肚子怎么办 肾结石怎么引起的 臀围怎么量