-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathslcmScrape.py
68 lines (59 loc) · 2.35 KB
/
slcmScrape.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
67
68
import requests
import smtplib
import threading
import sys
from bs4 import BeautifulSoup
path='slcmData.txt'
file = open(path,'w')
opt=int(input('Individual search(0) or Group Search(1)? : '))
if opt==1:
i=int(input('Enter Starting Roll number: '))
limit=int(input('Enter number of ID needed: '))
j=0
print('REG NO',' ','NAME',' ','BLOCK',' ','COLLEGE',' ','MESS DUES')
print('------------------------------------------------------------------------------------------------------------')
while j<limit:
link='http://sis.manipal.edu/HostelduesSLCM.aspx?roll='+str(i)
page= requests.get(link)
soup= BeautifulSoup(page.content, 'html.parser')
name=soup.find_all(id="ctl00_ContentPlaceHolder1_lblname")[0].get_text()
if(len(name)>0):
block=soup.find_all(id="ctl00_ContentPlaceHolder1_lblblock")[0].get_text()
college=soup.find_all(id='ctl00_ContentPlaceHolder1_LblInst2')[0].get_text()
try:
hosteldue=soup.find_all(id='ctl00_ContentPlaceHolder1_GridView5_ctl10_lbl_amtbalance5')[0].get_text()
except IndexError:
hosteldue='NOT FOUND'
s1=str((25-len(name))*' ')
s2=str((15-len (block))*' ')
info=str(str(i)+" "+str(name)+str(s1)+str(block)+str(s2)+str(college)+" "+hosteldue+'\n')
file.write(info)
print(info)
j=j+1
i=i+1
if opt==0:
i=input('Enter Roll number: ')
print(' ')
link='http://sis.manipal.edu/HostelduesSLCM.aspx?roll='+str(i)
page= requests.get(link)
soup= BeautifulSoup(page.content, 'html.parser')
name=soup.find_all(id="ctl00_ContentPlaceHolder1_lblname")[0].get_text()
if(len(name)>0):
block=soup.find_all(id="ctl00_ContentPlaceHolder1_lblblock")[0].get_text()
college=soup.find_all(id='ctl00_ContentPlaceHolder1_LblInst2')[0].get_text()
try:
hosteldue=soup.find_all(id='ctl00_ContentPlaceHolder1_GridView5_ctl10_lbl_amtbalance5')[0].get_text()
except IndexError:
hosteldue='NOT FOUND'
s1=str((25-len(name))*' ')
s2=str((15-len (block))*' ')
print("-----------------------------------------------------------------------------")
print('NAME:',name)
print('REG NO:', i)
print('HOSTEL:', block)
print('MESS DUES: Rs.',hosteldue)
print("-----------------------------------------------------------------------------")
else:
print('NO STUDENT ON THIS ROLL NO.')
print(' ')
file.close()