-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProjectSorting.py
47 lines (29 loc) · 947 Bytes
/
ProjectSorting.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
import requests
from bs4 import BeautifulSoup
import re
from bs4 import NavigableString
def ProjectSelector():
url = 'https://innovate.mygov.in/sih2018-search/'
source_code = requests.get(url)
plain_text = source_code.text
soup = BeautifulSoup(plain_text,"html.parser")
nos =[]
for div in soup.find_all(string = re.compile("Total Submissions")):
txt = str(div)
no=""
for i,c in enumerate(txt):
if i==41 or i==42 or i==43:
no = no + c
nos.append(int(no))
print(nos)
href = []
titles = []
for div in soup.find_all("div", class_="title"):
href.append(div.a.get('href'))
titles.append(div.a.get_text())
for i in range(len(titles)):
if(nos[i]<10):
print(nos[i],":"+titles[i]+":"+href[i])
#def surrounded_by_strings(tag):
# return (isinstance(tag.next_element, NavigableString))
ProjectSelector()