Last active
August 29, 2015 14:16
-
-
Save gabrii/6a9e8d1c0c7a57e394a7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
s = '''STRING CON TODO EL HTML CONTENIDO EN LA ETIQUETA <div class="message-list"...> de http://web.whatsapp.com/''' | |
s = BeautifulSoup(s) | |
s = s.findAll('div', {'class':'bubble bubble-text'}) | |
votes = {} | |
for l in s: | |
try: | |
autor = l.find('h3').text | |
msgs = l.findAll('div', {'class':'message-text'}) | |
for msg in msgs: | |
msg = msg.find('span').text | |
msg = msg.upper() | |
if 'VAGA SI' in msg: | |
r = 1 | |
elif 'VAGA NO' in msg: | |
r = 0 | |
elif 'VOTO EN BLANCO' in msg: | |
r = -1 | |
else: | |
r = None | |
if r != None: | |
if votes.has_key(autor): | |
print 'OVERRIDE_LAST_VOTE ->', | |
print '[',r,'] ', autor, '->', msg | |
votes[autor] = r | |
except Exception, E: | |
pass | |
sis = 0.0 | |
nos = 0.0 | |
bla = 0.0 | |
for k in votes.keys(): | |
if votes[k]==1: | |
sis+=1 | |
elif votes[k]==0: | |
nos+=1 | |
else: | |
bla+=1 | |
total = sis+nos+bla | |
print 'Participacion:', total | |
print '%SI:', sis/total*100 | |
print '%NO:', nos/total*100 | |
print '%BLACOS:', bla/total*100 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment