【发布时间】:2020-05-01 08:09:52
【问题描述】:
我正在尝试抓取网页。我想获得评论。但是评论分为三类,有些是正面的,有些是中性的,有些是负面的。我正在使用 html 解析器并访问了许多标签。但是对于可以分为三类的类,我怎样才能得到它们:
<div class="review positive" title="" style="background-color: #00B551;">9.3</div>
<div class="review negative" title="" style="background-color: #FF0000;">4.8</div>
<div class="review neutral" title="" style="background-color: #FFFF00;">6</div>
我为每个包含每个项目的 div 都有一个 python 容器:
# finds each product from the store page
containers = page_soup.findAll("div", {"class": "item-container"})`
for container in containers:
title = container.findAll(a).text #This gives me titles
##Similarly I need the reviews of each of them here
review = container.findAll("div", {"class": "review "}))#along with review there is positive, neutral and negative word also according to the type of review
【问题讨论】:
标签: web-scraping beautifulsoup html-parsing