Last active
December 20, 2017 00:37
-
-
Save hereismari/fe6298ed7f3e31b9ee73a9123667f3d7 to your computer and use it in GitHub Desktop.
GO UFCG 2017!
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
import Tkinter as tk | |
import tkMessageBox | |
import requests | |
import pandas as pd | |
import numpy as np | |
import time | |
url = "http://www.bombonera.org/score2017f2/score/#" | |
solved_problems = {} | |
pos_brasil = -1 | |
team_name = '[UFCG] Se juntas causa imagina juntas' | |
#team_name = '[UFCG] Choose difficulty: TITAN' | |
old_values = None | |
while True: | |
print 'buscando resultado...' | |
# request html | |
html = requests.get(url).content | |
# save as dataframe | |
df = pd.read_html(html)[-1] | |
# get team index and team values | |
index = df.index[df[2] == team_name].tolist()[1] | |
new_values = df.values[index] | |
if old_values is None or not bool(np.asarray(old_values == new_values).all()): | |
old_values = new_values | |
# check for updates | |
new_pos = new_values[0] | |
message_update = '' | |
if new_pos != pos_brasil: | |
message_update += 'Nova posicao: ' + str(new_pos) + '\n' | |
pos_brasil = new_pos | |
for i in xrange(3, len(new_values)-1): | |
questao = chr(ord('A') + i - 3) | |
if not pd.isnull(new_values[i]): | |
tried = str(new_values[i][-1]) == '-' | |
if not tried and (questao not in solved_problems or solved_problems[questao] == 'tried'): | |
message_update += 'Resolveram a ' + questao + '\n' | |
solved_problems[questao] = 'solved' | |
elif questao not in solved_problems: | |
if tried: | |
solved_problems[questao] = 'tried' | |
message_update += 'Tentaram a ' + questao + '\n' | |
if message_update != '': | |
message_update += 'Total de problemas resolvidos = ' + str(new_values[-1]) | |
root = tk.Tk() | |
root.withdraw() | |
tkMessageBox.showinfo('GO! ' + team_name, message_update) | |
time.sleep(30) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment