Sunday, March 13, 2016

Python script to Notify GTU exam results when uploaded.

Actually I recently made this type of script to check for my 3 Semester result. I used urllib2 and requests module to scrap through the result website.  This script does very simple thing it finds for the keyword of Result of Semester 3 if it founds nothing it goes into sleep for next 15 minutes and if it gets it sends notification to my Desktop ( I use ubuntu so notification won't work in windows ).
Here is the code.
  1. #This is a script checks for Result of 3 sem every 15 Min
  2. #Author Harit Dholakia
  3. #Just for Fun
  4. import urllib2
  5. import re
  6. import os
  7. import time
  8.  
  9. while 1:
  10.  
  11. html_content = urllib2.urlopen('http://www.gtu.ac.in/results.asp').read()
  12.  
  13. matches = re.findall('MCA SEM 3', html_content);
  14.  
  15.  
  16. if len(matches) == 0:
  17. os.system("notify-send 'Yeah' 'Result is not declared yet'")
  18. time.sleep(900)
  19.  
  20. else:
  21. os.system("notify-send 'Oops' 'Result Declared'")
  22. quit()
Here the output.
I kept this script running for two days and I was the First one the get the news of Result.
I luckily scored good marks. :) :)

No comments:

Post a Comment

Xiaomi Launches 32-inch and 43-inch Mi TV 4A in India, Price Starting At ₹13,999

After launching the Mi TV 4 in India, Xiaomi has launched two new affordable smart TVs in India. The company has introduced a 43-inch ...