我试图从屏幕截图中发布的html中提取评级。它嵌入在div下的标题中。以下代码返回“无”
HTML:
from bs4 import BeautifulSoup
html_soup = BeautifulSoup(response.text, 'html.parser')
type(html_soup)
rest_container = html_soup.find_all('div',
class_ = 'i-stars i-stars--regular-5 rating-large')
first_rest=rest_container[0]
print (first_rest.text)
答案 0 :(得分:2)
您尚未提供足够的元素供我们为您提供任何解决方案。但是,请试一试。只需在脚本中输入url
即可。希望它至少能取得你的评价。
from bs4 import BeautifulSoup
import requests
url = "" #input webpage link here
res = requests.get(url)
soup = BeautifulSoup(res.text, 'html5lib')
for rating in soup.select(".rating-large"):
print(rating.get("title"))