maybe my terminology is a bit off here, but hope you get the jist. I'm trying to scrape data off a food review website which has three ratings: happy, neutral, unhappy. The number of counts of each in the website written like:
<div class="col PL20">
<div class="sprite-sr2-face-smile1"></div>
<div class="sr2_score_l">25</div>
</div>
<div class="col MR20 MT20 ML20">
<div class="sprite-sr2-face-ok2 MT20"></div>
<div class="sr2_score_m">17</div>
</div>
<div class="col ML10 MT20">
<div class="sprite-sr2-face-cry2 MT20"></div>
<div class="sr2_score_m">2</div>
</div>
So in this case the number of happy counts is 25, neutral is 17 and unhappy is 2. Problem is what with my python code below I cannot differentiate between the neutral count and the unhappy count because the share the same class, is there a way around this?
# using BeautifulSoup4 and lxml
import urllib2
from bs4 import BeautifulSoup
soup = BeautifulSoup(urllib2.urlopen('http://www.openrice.com/_
en/hongkong/restaurant/central-open-kitchen/136799').read())
happy = soup.find('div', attrs={'class': 'sr2_score_l'})
print "happy rating, " + happy.string
neutral = soup.find('div', attrs={'class': 'sr2_score_m'})
print "neutral rating, " + neutral.string
unhappy = soup.find('div', attrs={'class': 'sr2_score_m'})
print "neutral rating, " + neutral.string