import requests from bs4 import BeautifulSoup import re sum = 0 r = requests.get('https://book.douban.com/subject/5299764/comments/') soup = BeautifulSoup(r.text, 'lxml') pattern = soup.find_all('p','comment-content') for item in pattern: print(item.string) pattern_s = re.compile('<span class="user-stars allstar(.*?) rating"') p = re.findall(pattern_s, r.text) for star in p: sum += int(star) print(sum)
这个问题怎么解决?求大神指教。
慕斯5016438
相关分类