这是网站......
右键单击检查页面中间海报下面的标题会显示代码。我从教程到发布过程中尝试了太多变化。 这就是我的Python脚本......
import requests
from bs4 import BeautifulSoup
url = "https://www.rottentomatoes.com/browse/dvd-top-rentals/?services=amazon;amazon_prime;fandango_now;hbo_go;itunes;netflix_iw;vudu"
r = requests.get(url)
soup = BeautifulSoup(r.content, "lxml")
答案 0 :(得分:2)
此页面由JavaScript呈现,requests
仅返回html代码:
真实数据在此网址中:
https://www.rottentomatoes.com/api/private/v2.0/browse?page=1&limit=30&type=dvd-top-rentals&services=amazon%3Bamazon_prime%3Bfandango_now%3Bhbo_go%3Bitunes%3Bnetflix_iw%3Bvudu&sortBy=popularity
代码:
import requests
r = requests.get('https://www.rottentomatoes.com/api/private/v2.0/browse?page=1&limit=30&type=dvd-top-rentals&services=amazon%3Bamazon_prime%3Bfandango_now%3Bhbo_go%3Bitunes%3Bnetflix_iw%3Bvudu&sortBy=popularity')
data = r.json()
for result in data["results"]:
print(result["title"], result["tomatoScore"])
出:
The Girl on the Train 43
Keeping Up With The Joneses 19
Ouija: Origin of Evil 82
Long Way North (Tout en haut du monde) 98
The Whole Truth 29
Come And Find Me 67
LEGO Jurassic World: The Indominus Escape None
My Father, Die 88
When Elephants Were Young None
Roger Corman's Death Race 2050 None
Take the 10 None
Deepwater Horizon 83
The Accountant 51
The Birth of a Nation 72
Kevin Hart: What Now? 76
答案: