代码:
from urllib.request import urlopen
from bs4 import BeautifulSoup
html=urlopen("https://www.baidu.com/")
bsobj=BeautifulSoup(html.read(),)
print(bsobj)
报错:
The code that caused this warning is on line 4 of the file XXX. To get rid of this warning, pass the additional argument 'features="html.parser"' to the BeautifulSoup constructor.
bsobj=BeautifulSoup(html.read(),)
解决:
from urllib.request import urlopen
from bs4 import BeautifulSoup
html=urlopen("https://www.baidu.com/")
bsobj=BeautifulSoup(html.read(),"html.parser")
print(bsobj)