-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatepgTheory.py
More file actions
36 lines (34 loc) · 854 Bytes
/
datepgTheory.py
File metadata and controls
36 lines (34 loc) · 854 Bytes
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
import requests
from bs4 import BeautifulSoup as bs
import MySQLdb
db=MySQLdb.connect("localhost","root","icancode23","dufeed")
cursor2=db.cursor()
cmd="""select * from api_pgdatecounters"""
cursor2.execute(cmd)
alt=cursor2.fetchone()
db.commit()
#last_notification="run"
src=requests.get("http://exam.du.ac.in/PG-datesheets.html").text
soup=bs(src,"html.parser")
j=21
soup1=soup.find_all('a')
soup2=soup1[21]
href=soup2
print soup2
while soup2!=last_notification and j<141:
#print soup2
try:
link=soup2["href"]
name=soup2.decode_contents(formatter="html")
print name
print "\n"
except:
print "nahi hai"
j=j+1
print j
soup2=soup1[j]
sql="""insert into api_pgdate(id,link,title) values(NULL,'%s','%s')"""%(link,name)
cursor2.execute(sql)
cursor2.execute("""update api_pgdatecounters set link=%s""",(href,))
db.commit()
db.close()