Skip to content

Commit 90c668c

Browse files
authored
Add files via upload
1 parent 9d12558 commit 90c668c

File tree

1 file changed

+178
-0
lines changed

1 file changed

+178
-0
lines changed

SemPapers.py

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
import prettytable
2+
import webbrowser
3+
import requests
4+
import itertools
5+
import threading
6+
import time
7+
import sys
8+
from bs4 import BeautifulSoup
9+
from prettytable import PrettyTable
10+
from time import sleep
11+
from sys import exit
12+
13+
def year(url):
14+
try:
15+
page = requests.get(url)
16+
soup = BeautifulSoup(page.content,'html.parser')
17+
18+
19+
div=soup.findAll('div', xmlns="http://di.tamu.edu/DRI/1.0/")
20+
ul=div[0].findAll('ul')
21+
li=ul[0].findAll('li')
22+
hyper=li[0].a['href']
23+
url='http://dspace.amritanet.edu:8080/'
24+
url+=hyper
25+
page = requests.get(url)
26+
soup = BeautifulSoup(page.content,'html.parser')
27+
t=PrettyTable(['No','Subjects'])
28+
div=soup.findAll('div', class_="file-list")
29+
subdiv=div[0].findAll('div',class_="file-wrapper clearfix")
30+
for i in range(len(subdiv)):
31+
title=subdiv[i].findAll('div')
32+
span=title[1].div.findAll('span')
33+
t.add_row([i+1,span[1]['title']])
34+
t.align='l'
35+
print(t)
36+
while(True):
37+
ch=int(input("Enter your choice: "))
38+
if(ch>0 and ch<=len(subdiv)):
39+
title=subdiv[ch-1].findAll('div')
40+
link=title[0].a['href']
41+
url='http://dspace.amritanet.edu:8080/'
42+
url+=link
43+
break
44+
else:
45+
print("Please enter a valid input!")
46+
except:
47+
print("UNEXPECTED ERROR! :(")
48+
exit()
49+
print("Please wait till the browser opens ! ")
50+
webbrowser.open(url, new=0, autoraise=True)
51+
ch=int(input('Do you want to continue ? \nPress 1 for Yes and 0 for No : '))
52+
if(ch==0):
53+
exit()
54+
else:
55+
start()
56+
57+
58+
59+
60+
61+
62+
63+
def semchoose(url):
64+
try:
65+
page = requests.get(url)
66+
soup = BeautifulSoup(page.content,'html.parser')
67+
68+
t=PrettyTable(['No','Available Assessments'])
69+
div=soup.findAll('div', id="aspect_artifactbrowser_CommunityViewer_div_community-view")
70+
ul=div[0].findAll('ul')
71+
if(len(ul)>1):
72+
li=ul[1].findAll('li')
73+
else:
74+
li=ul[0].findAll('li')
75+
76+
for i in range(len(li)):
77+
t.add_row([i+1,li[i].a.text.strip()])
78+
t.align = "l"
79+
print(t)
80+
while(True):
81+
ch=int(input("Enter your choice: "))
82+
if(ch>0 and ch<=len(li)):
83+
url='http://dspace.amritanet.edu:8080/'
84+
url+=li[ch-1].a['href']
85+
break
86+
else:
87+
print("Please enter a valid input !")
88+
except:
89+
print("\nUNEXPECTED ERROR ! :( ")
90+
sleep(3)
91+
exit()
92+
year(url)
93+
94+
95+
def start():
96+
url="http://dspace.amritanet.edu:8080/xmlui/handle/123456789/"
97+
try:
98+
page = requests.get(url)
99+
print("\n")
100+
t=PrettyTable(['No','Courses'])
101+
t.add_row(["1","B.Tech"])
102+
t.add_row(["2","BA Communication"])
103+
t.add_row(["3","MA Communication"])
104+
t.add_row(["4","Integrated MSc & MA"])
105+
t.add_row(["5","MCA"])
106+
t.add_row(["6","MSW"])
107+
t.add_row(["7","M.Tech"])
108+
t.align="l"
109+
print(t)
110+
while(True):
111+
print("\n")
112+
ch=int(input("Enter your choice : "))
113+
if(ch<8 and ch>0):
114+
if(ch==1) :
115+
url+="150"
116+
elif(ch==2) :
117+
url+="893"
118+
elif(ch==3) :
119+
url+="894"
120+
elif(ch==4) :
121+
url+="903"
122+
elif(ch==5) :
123+
url+="331"
124+
elif(ch==6) :
125+
url+="393"
126+
elif(ch==7) :
127+
url+="279"
128+
break
129+
else:
130+
print("Please enter a valid input ! ")
131+
page = requests.get(url)
132+
soup = BeautifulSoup(page.content,'html.parser')
133+
134+
135+
136+
t=PrettyTable(['No','Semesters'])
137+
div=soup.findAll('div', id="aspect_artifactbrowser_CommunityViewer_div_community-view")
138+
li=div[0].ul.findAll('li')
139+
140+
for i in range(len(li)):
141+
t.add_row([i+1,li[i].a.text.strip()])
142+
t.align = "l"
143+
print(t)
144+
while(True):
145+
ch=int(input("Enter your semester : "))
146+
if(ch>0 and ch<=len(li)):
147+
url='http://dspace.amritanet.edu:8080/'
148+
url+=li[ch-1].a['href']
149+
break
150+
151+
else:
152+
print("Please enter a valid input !")
153+
except:
154+
print("\nOOPS! There was an unexpected error.\nExiting in few seconds... ")
155+
sleep(4)
156+
exit()
157+
semchoose(url)
158+
159+
160+
161+
162+
163+
164+
url="http://dspace.amritanet.edu:8080"
165+
print("\nHELLO! Ever wanted to use Amrita Repository on PC ? \nWell, here's my Python Script that does the same job as the app. \nHave a look at your question papers without wasting time !! \n")
166+
print("Please ensure you're connected to Amrita Wi-Fi for a smooth experience :)\n")
167+
print("Report bugs to : [email protected]")
168+
print("(c) 2018 Rajkumar\n")
169+
done=10
170+
for c in itertools.cycle(['|', '/', '-', '\\']):
171+
if not(done):
172+
break
173+
sys.stdout.write('\rPlease wait..' + c)
174+
sys.stdout.flush()
175+
done=done-1
176+
time.sleep(0.1)
177+
sys.stdout.flush()
178+
start()

0 commit comments

Comments
 (0)