|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
然后照着书上打了一遍没有返回任何东西……
求各位大佬帮忙解决一下
哪有问题可以提出
下面是代码:
import bs4
import requests
res = requests.get("https://movie.douban.com/top250")
print(res.text)
soup = bs4.BeautifulSoup(res.text, "html.parser")
targets = soup.find_all("div", class_="hd")
for each in targets:
print(each.a.span.text)
新手上路,各位多多关照!感谢!!!
- import bs4
- import requests
- headers = {
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36 Edg/88.0.705.56",
- }
- res = requests.get("https://movie.douban.com/top250", headers=headers)
- print(res.text)
- soup = bs4.BeautifulSoup(res.text, "html.parser")
- targets = soup.find_all("div", class_="hd")
- for each in targets:
- print(each.a.span.text)
复制代码
|
|