Created
February 24, 2015 13:51
-
-
Save gabrii/20a865343e7b34c688d4 to your computer and use it in GitHub Desktop.
This file contains 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/ DEL GRUPO CON TODOS LOS MENSAJES CARGADOS''' | |
s = BeautifulSoup(s) | |
s = s.findAll('div', {'class':'bubble bubble-text'}) | |
votes = {} | |
for l in s: | |
try: | |
autor = l.find('h3').text | |
msg = l.find('div', {'class':'message-text'}).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: | |
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