Skip to content

Instantly share code, notes, and snippets.

@ketanhwr
Created May 24, 2017 16:05
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ketanhwr/50ad9b310b8dff3439851a398b542732 to your computer and use it in GitHub Desktop.
Save ketanhwr/50ad9b310b8dff3439851a398b542732 to your computer and use it in GitHub Desktop.
Gives a notification along with rank whenever an Indian team solves a new problem in ICPC World Finals!
from bs4 import BeautifulSoup
import requests
import pynotify
import time
def sendmessage(title, message):
pynotify.init("Test")
notice = pynotify.Notification(title, message)
notice.show()
return
names = ["Dhirubhai Ambani Institute of Information and Communication Technology, Gandhinagar",
"Indian Institute of Technology - Indore",
"Indian Institute of Technology - Kanpur",
"Indian Institute of Technology - Bombay",
"International Institute of Information Technology - Hyderabad",
"International Institute of Information Technology - Bangalore",
"Chennai Mathematical Institute",
"National Institute of Technology, Karnataka"]
solved = [0, 0, 0, 0, 0, 0, 0, 0]
r = requests.get('https://icpc.baylor.edu/scoreboard/')
soup = BeautifulSoup(r.text, 'html.parser')
rows = soup.find_all('tr')
print "Initialising!"
i = 0
for row in rows:
for name in names:
if name in str(row):
print name + ": " + row.find_all('td')[0].string
solved[i] = int(row.find_all('td')[3].string)
i = i+1
print solved
while True:
r = requests.get('https://icpc.baylor.edu/scoreboard/')
soup = BeautifulSoup(r.text, 'html.parser')
rows = soup.find_all('tr')
i = 0
for row in rows:
for name in names:
if name in str(row):
print name + ": " + row.find_all('td')[0].string
new_solved = int(row.find_all('td')[3].string)
if new_solved != solved[i]:
solved[i] = new_solved
sendmessage(name + " solved another problem!", "Their new rank is " + row.find_all('td')[0].string)
i = i+1
time.sleep(60)
@ketanhwr
Copy link
Author

Make sure you install the following packages: beautifulsoup4, py-notify, requests.
Just start up the script by python icpc-rank-notifier.py 🙂

P.S.: I made this in 15 min and I don't code in Python much, so don't judge me by the code.

@mohanagr
Copy link

mohanagr commented May 24, 2017

P.S.: I made this in 15 min and I don't code in Python much, so don't judge me by the code.

tatti 💯 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment