请教:
星级的源码是这样的,如何用python3爬取星级呢?

初学者,求大佬们赐教o(╥﹏╥)o
其他的书名和价格都可以拿到,就是这个星级不知道咋办
import requests
from bs4 import BeautifulSoup
res=requests.get('http://books.toscrape.com/catalogue/category/books/travel_2/index.html')
html=res.text
book=BeautifulSoup(html,'html.parser')
items=book.find_all(class_="product_pod")
for item in items:
name=item.find('h3')
rate=item.find(class_="star-rating")
price=item.find(class_="price_color")
print(name.text,'\n',rate.text,'\n',price.text)
本文介绍了一个Python爬虫示例,演示了如何从网页中抓取书籍的名称、价格及星级等信息。对于初学者而言,这是一个很好的实践案例,能够帮助理解BeautifulSoup和requests库的基本使用。
1656





