极客python之效率革命,爬取豆瓣top250
求助大佬。根据小甲鱼的代码和一些补充,结果能输出,但是会有警告:InsecureRequestWarning
要怎么消除。
这是我的代码
import requests
import bs4
import urllib3
headers = {# 头部变量主要储存代理信息,伪装浏览器
"user-agent": "Mozilla/5.0 (Windows NT 10.0; WOW64)"
" AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"}
res = requests.get("https://movie.douban.com//top250", headers=headers, verify=False)
# requests.packages.urllib3.disable_warnings()
soup = bs4.BeautifulSoup(res.text, "html.parser")
targets = soup.find_all("div", class_="hd")
for each in targets:
print(each.a.span.text) https://blog.csdn.net/qq_39377418/article/details/89673171 b站过来学习{:5_109:}
页:
[1]