-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ignou_Result_Scraper.py
66 lines (52 loc) · 2.02 KB
/
Ignou_Result_Scraper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
########################################################################
## IGNOU RESULTS SCRAPER ##
########################################################################
from splinter import Browser
import time
import os
count = 0 #Global variable to assign image filenames
########################################################################
##Function To Traverse Through The Results Website
########################################################################
def traverse(url):
browser = Browser()
browser.visit(url)
file = open('student_list.txt')
enrollment_no = file.read().split()
for line in enrollment_no:
time.sleep(1)
browser.fill("eno",line)
button = browser.find_by_value('Submit').click()
time.sleep(3)
capture()
button = browser.click_link_by_text('Back ')
file.close()
########################################################################
##Function To Capture Screenshots
########################################################################
def capture():
global count
count = count + 1
command = "import -window root %r.png" %count
os.system(command)
########################################################################
##Function To Create Pdf using Images Created Earlier
########################################################################
def createPdf():
os.system('convert *.png Results.pdf')
########################################################################
##Function To Cleanup The Mess
########################################################################
def cleanup():
files = [f for f in os.listdir('.') if f.endswith('.png')]
for f in files:
os.remove(f)
########################################################################
##Script Driver
########################################################################
url = raw_input('Enter The Results URL: \n')
traverse(url)
createPdf()
cleanup()
########################################################################
########################################################################