求助 豆瓣电影top250代码问题
求问一下,小甲鱼老师的代码复制过来运行,为啥什么结果都没出来 https://fishc.com.cn/forum.php?mod=viewthread&tid=180063 @不二如是 请帮忙把主题移动到 Python 交流板块 你确定访问拿到数据了,做个headers 头文件 在访问数据源吧 import requestsimport bs4
headers={'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1'}
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) zltzlt 发表于 2020-10-3 08:17
https://fishc.com.cn/forum.php?mod=viewthread&tid=180063
啊呸,我的求助帖 import requests
import bs4
headers={'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1'}
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) 感谢大家 zltzlt 发表于 2020-10-3 08:20
@不二如是 请帮忙把主题移动到 Python 交流板块
发错版块了么{:10_266:}
页:
[1]