Last active
June 28, 2018 16:35
-
-
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)
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 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) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
COOL!