import urllib.request
from urllib import request
from bs4 import BeautifulSoup
from html.parser import HTMLParser
url = 'https://pic.netbian.com/'
#1.添加头部信息
def geturl(url):
headers = {"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:86.0) Gecko/20100101 Firefox/86.0"}
rep = urllib.request.Request(url,headers=headers)
page = urllib.request.urlopen(rep,timeout=10)
connects = page.read()
#print(contents)#(检测能否爬取)
#2.解析出图片链接
soup = BeautifulSoup(connects,'html.parse')
img_url = soup.find_all('img')
print(img_url)
geturl(url)
#运行结果
Traceback (most recent call last):
File "G:/python/test2.py", line 19, in <module>
geturl(url)
File "G:/python/test2.py", line 16, in geturl
soup = BeautifulSoup(connects,'html.parse')
File "G:\python\lib\site-packages\bs4\__init__.py", line 243, in __init__
raise FeatureNotFound(
bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: html.parse. Do you need to install a parser library?
Process finished with exit code 1
求解?