该怎么办的
看了小甲鱼的极客python爬虫结果呢。。。。{:10_284:} {:10_284:}
import requests
import bs4
res = requests.get("https://movie.douban.com/top250")
soup = bs4.BeautifulSoup(res.text,"html.parser")
targets = soup.find_all("div", class_="hd")
for each in targets:
print(each.a.span.text)
我打入这些代码后运行就发现
这个东西根本就跑不起来
根本就不会去打印那一些电影名
这是怎么回事{:10_243:} {:10_243:} {:10_243:}
豆瓣有反爬
import requests
import bs4
headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36"}
res = requests.get("https://movie.douban.com/top250",headers=headers)
soup = bs4.BeautifulSoup(res.text,"html.parser")
targets = soup.find_all("div", class_="hd")
for each in targets:
print(each.a.span.text) 不知道啊,我也是刚接触,我从网上复制的代码也跑不起来 临时号 发表于 2022-8-15 19:08
豆瓣有反爬
牛哇,膜拜{:10_286:}
页:
[1]