Ever got tensed or wondered when the heck is result gonna come out ? Well , I am currently studying in Mumbai University and I am never sure when the results come out , actually MU(Mumbai University) prefers to launch the results at the unexpected time of the day , when no one in the world would dare to think .
So , as one of the nerd/lazy student of my college , I got a very stupid yet interesting idea(well , i believe that laziness is something that helps for mental improvement), why not write a script to check for the results ? And as stupid it might sound , its incredibly simple if you use some language like Python . So here's what I did :
Generally , result links are dynamic , but the webpage to that link are static and are updated when they launch the results , so considering this - I made a simple python script that would sound a alarm on my laptop and email me when the results are out .
So , here's the code , the code is pretty self explanatory (with the comments)
So , as one of the nerd/lazy student of my college , I got a very stupid yet interesting idea(well , i believe that laziness is something that helps for mental improvement), why not write a script to check for the results ? And as stupid it might sound , its incredibly simple if you use some language like Python . So here's what I did :
Generally , result links are dynamic , but the webpage to that link are static and are updated when they launch the results , so considering this - I made a simple python script that would sound a alarm on my laptop and email me when the results are out .
So , here's the code , the code is pretty self explanatory (with the comments)
import urllib2 # used for getting the exam result url import re # Regular expressions , used for comparing the last updated date with the current updated date import time # for sleeping import smtplib # for sending emailsm from pygame import mixer # used for playing sounds from email.mime.text import MIMEText # for composing the email to send resultUrl='http://mu.ac.in/res_be7r.html' # the url address where the results are expected to be updated while (1==1): # while true , infinite loop :) f=urllib2.urlopen(resultUrl) # request the url metaInfo=f.info(); # get webpage info , specifically last update info match=re.search('Last-Modified: Sat, 25 Feb 2012 15:14:03 GMT',str(metaInfo)) # compare with last modified info ( as per you last webpage visit if(match==None): # ie , the result webpage has been updated (TENSED .... :( :( ) mixer.init() #you must initialize the mixer alert=mixer.Sound('/home/tapan/COWBELL.WAV') # initialize the sound to be played as alarm fromaddr = 'tapan.genius@gmail.com' # from addr toaddrs = 'tapan.terna@gmail.com' # to addr msg = MIMEText('The results seem to be updated , please check!!') msg['Subject']='RESULTS!!!!!' # Credentials (if needed) username = 'tapan.genius@gmail.com' # email id from which the email should be sent password = '***********' # you password # The actual mail send server = smtplib.SMTP('smtp.gmail.com:587') server.starttls() server.login(username,password) server.sendmail(fromaddr, toaddrs, msg.as_string()) server.sendmail(fromaddr,'aankitt.jain@yahoo.com', msg.as_string()) server.quit() while (1==1): alert.play() time.sleep(1) print('results are not yet out') time.sleep(120) # wait for 2 mins and check again .
Ps : I am drunk right now , so please forgive my typing/grammatical mistakes (Actually results came and and i FAILED :( )