关于一点request和beautifulsoup的问题
import requestsimport bs4
res = requests.get("https://movie.douban.com/top250")
print(res.text)
soup = bs4.BeautifulSoup(res.text, "html.parser")
target = soup.find_all("div", class_="hd")
for each in target:
print(each.a.span.text)
为什么我在pycharm里面运行,没有报错,也没有打印结果呢? headers = {'user-agent': 'Mozilla'}# 修改默认的user-agent, 否则会被豆瓣反扒
res = requests.get("https://movie.douban.com/top250", headers=headers) suchocolate 发表于 2021-11-29 22:39
谢谢回答!!!
页:
[1]