我正在为我的大学项目从红薯上刮一些数据,但我不能刮番茄机的分数。
https://www.rottentomatoes.com/m/doctor_strange_in_the_multiverse_of_madness

我的代码是
tomato = bs.find('span', {'class':'percentage'}, {'data-qa':'tomatometer'}).text我试过几种方法,但没有一种奏效
发布于 2022-05-09 21:15:02
您看到的数据存储在页面中的<score-board>标记中:
import requests
from bs4 import BeautifulSoup
url = "https://www.rottentomatoes.com/m/doctor_strange_in_the_multiverse_of_madness"
soup = BeautifulSoup(requests.get(url).content, "html.parser")
board = soup.find("score-board")
print(
f'Audience Score: {board["audiencescore"]}% Tomatometer: {board["tomatometerscore"]}%'
)指纹:
Audience Score: 87% Tomatometer: 75%https://stackoverflow.com/questions/72176548
复制相似问题