# def find_thing(): def gethtml(url):
html = "" headers = { "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36" }
req = urllib.request.Request(url, headers=headers)
response = urllib.request.urlopen(req)
print(response.read().decode("utf-8")) # return html def getdata(baseurl):
datalist = [] for i in range(0,1):
url = baseurl + str(i*25)
html = gethtml(url)
soup = BeautifulSoup(html,"html.parser") for item in soup.find_all('div',class_ ="item"):
datalist.append(item)
if __name__ == '__main__':
main()
Traceback (most recent call last):
File "C:/Users/11929/PycharmProjects/untitled1/htmlfirst.py", line 47, in <module>
main()
File "C:/Users/11929/PycharmProjects/untitled1/htmlfirst.py", line 13, in main
getdata(baseurl = "https://movie.douban.com/top250?start=0")
File "C:/Users/11929/PycharmProjects/untitled1/htmlfirst.py", line 37, in getdata
soup = BeautifulSoup(html,"html.parser")
File "C:\Users\11929\AppData\Local\Programs\Python\Python36\lib\site-packages\bs4\__init__.py", line 310, in __init__
elif len(markup) <= 256 and (
TypeError: object of type 'NoneType' has no len()
作者: crossin先生 时间: 2020-10-14 16:38
html = gethtml(url)