Skip to content

Instantly share code, notes, and snippets.

@yagyanshbhatia
Last active June 28, 2018 16:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save yagyanshbhatia/8d9f3c18b3daba837f61d5626072aba5 to your computer and use it in GitHub Desktop.
Save yagyanshbhatia/8d9f3c18b3daba837f61d5626072aba5 to your computer and use it in GitHub Desktop.
Tired of checking repeatedly for rating on codeforces to change? why not automate it with this script B)
from urllib.request import urlopen
import urllib
from bs4 import BeautifulSoup
import time
import pymsgbox
#taking the required variables
print("what is your current rating? ")
curr = str(input())
print("Enter your username: ")
username = str(input())
print()
print("Cool. I'll Notify you when it changes. Till then, take a chill pill ;)")
print()
#loop until detect the changes
while 1:
url = "http://codeforces.com/profile/" + username
try :
page = urlopen(url)
except Exception as e:
print("tryin' again.")
continue
bsobj = BeautifulSoup(page, 'html.parser')
name_box = str(bsobj.find("div", attrs={"class": "info"}))
yash = name_box.split('" style="font-weight:bold;">')[1]
rating = yash.split('</span>')
if rating[0] != curr:
if int(rating[0]) < int(curr):
pymsgbox.alert("Your new rating is : " + rating[0], 'sorry!')
else:
pymsgbox.alert("Your new rating is : " + rating[0], 'Congratulations!')
break
else:
time.sleep(10)
@EktaDhan
Copy link

COOL!

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