Skip to content

Commit 8d6a739

Browse files
Harsh GandhiHarsh Gandhi
Harsh Gandhi
authored and
Harsh Gandhi
committed
google-search
1 parent 89581c9 commit 8d6a739

6 files changed

+105
-36
lines changed

app.py

+95-28
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,88 @@
44
from requests.packages.urllib3.exceptions import InsecureRequestWarning
55
from flask_session import Session
66
import pandas as pd
7-
7+
try:
8+
from googlesearch import search
9+
except ImportError:
10+
print("No module named 'google' found")
811

912
deptDict = {
10-
'Aerospace Engineering': ['https://www.aero.iitb.ac.in/home/people/faculty','https://www.aero.iitb.ac.in/home/people/former-faculty'],
11-
'Biosciences and Bioengineering':['https://www.bio.iitb.ac.in/people/faculty/'],
12-
'Chemical Engineering':['https://www.che.iitb.ac.in/faculty-directory'],
13-
'Chemistry':[],
14-
'Civil Engineering':['https://www.civil.iitb.ac.in/faculty'],
15-
'Computer Science & Engineering':[],
16-
'Earth Sciences':[],
17-
'Electrical Engineering':[],
18-
'Energy Science and Engineering':['https://www.me.iitb.ac.in/?q=full-time-faculty'],
19-
'Environmental Science and Engineering (ESED)':['http://www.esed.iitb.ac.in/faculty-directory'],
20-
'Humanities & Social Sciences':[],
21-
'Mathematics':[],
22-
'Mechanical Engineering':['http://www.esed.iitb.ac.in/faculty-directory','https://www.me.iitb.ac.in/?q=honorary-faculty-members'],
23-
'Metallurgical Engineering & Materials Science':[],
24-
'Physics':['https://www.phy.iitb.ac.in/en/faculty'],
25-
'All':
26-
[
13+
'Aerospace Engineering': {
14+
'list': ['https://www.aero.iitb.ac.in/home/people/faculty','https://www.aero.iitb.ac.in/home/people/former-faculty'],
15+
'query': 'iit Aerospace Engineer faculty name',
16+
},
17+
'Biosciences and Bioengineering':{
18+
'list':['https://www.bio.iitb.ac.in/people/faculty/'],
19+
'query': 'iit Biosciences and Bioengineer faculty name',
20+
},
21+
'Chemical Engineering':{
22+
'list':['https://www.che.iitb.ac.in/faculty-directory'],
23+
'query': 'iit Chemical Engineer faculty name',
24+
},
25+
'Chemistry':{
26+
'list':[],
27+
'query': ''
28+
},
29+
'Civil Engineering':{
30+
'list':['https://www.civil.iitb.ac.in/faculty'],
31+
'query': ''
32+
},
33+
'Computer Science & Engineering':{
34+
'list':[],
35+
'query': ''
36+
},
37+
'Earth Sciences':{
38+
'list':[],
39+
'query': ''
40+
},
41+
'Electrical Engineering':{
42+
'list':[],
43+
'query': ''
44+
},
45+
'Energy Science and Engineering':{
46+
'list':['https://www.me.iitb.ac.in/?q=full-time-faculty'],
47+
'query': ''
48+
},
49+
'Environmental Science and Engineering (ESED)':{
50+
'list':['http://www.esed.iitb.ac.in/faculty-directory'],
51+
'query': ''
52+
},
53+
'Humanities & Social Sciences':{
54+
'list':[],
55+
'query': ''
56+
},
57+
'Mathematics':{
58+
'list':[],
59+
'query': ''
60+
},
61+
'Mechanical Engineering':{
62+
'list':['http://www.esed.iitb.ac.in/faculty-directory','https://www.me.iitb.ac.in/?q=honorary-faculty-members'],
63+
'query': ''
64+
},
65+
'Metallurgical Engineering & Materials Science':{
66+
'list':[],
67+
'query': ''
68+
},
69+
'Physics':{
70+
'list':['https://www.phy.iitb.ac.in/en/faculty'],
71+
'query': ''
72+
},
73+
'All': {
74+
'list':[
2775
'https://www.aero.iitb.ac.in/home/people/faculty',
2876
'https://www.aero.iitb.ac.in/home/people/former-faculty',
2977
'https://www.bio.iitb.ac.in/people/faculty/','https://www.che.iitb.ac.in/faculty-directory',
3078
'https://www.civil.iitb.ac.in/faculty','https://www.me.iitb.ac.in/?q=full-time-faculty',
31-
'http://www.esed.iitb.ac.in/faculty-directory','http://www.esed.iitb.ac.in/faculty-directory','https://www.me.iitb.ac.in/?q=honorary-faculty-members'
79+
'http://www.esed.iitb.ac.in/faculty-directory','http://www.esed.iitb.ac.in/faculty-directory','https://www.me.iitb.ac.in/?q=honorary-faculty-members',
3280
'https://www.phy.iitb.ac.in/en/faculty','https://en.wikipedia.org/wiki/List_of_IIT_Bombay_people',
3381
'https://www.iitbbs.ac.in/faculty-members.php',
3482
'https://iitpkd.ac.in/faculty-list',
3583
'https://iith.ac.in/people/faculty/',
3684
'http://www.iitkgp.ac.in/department/AE/faculties'
37-
38-
]
85+
],
86+
'query': 'indian engineering faculty names'
87+
},
88+
3989
}
4090

4191
app = Flask(__name__,static_folder='./static')
@@ -52,18 +102,22 @@ def index():
52102
req = request.form
53103
# print(req)
54104
req_table = req.to_dict()
105+
print("==========================================================================================")
106+
print(req_table)
107+
print("==========================================================================================")
55108

56-
if not session.get("dept_name"):
57-
# session['dept_name'] = req['dept_name']
58-
session['dept_name'] = 'All'
59109

60-
session['research_name'] = req['research_name']
110+
if not session.get("dept_name") or 'dept_name' in req_table:
111+
session['dept_name'] = req['dept_name']
112+
# session['dept_name'] = 'All'
113+
114+
# session['research_name'] = req['research_name']
61115
session['web_prev'] = False
62116

63117
# if 'dept_name' in req_table and 'research_name' in req_table:
64118
if 'research_name' in req_table:
65119
# session['dept_name'] = req['dept_name']
66-
session['dept_name'] = 'All'
120+
# session['dept_name'] = 'All'
67121

68122
session['research_name'] = req['research_name']
69123
session['web_prev'] = False
@@ -113,12 +167,25 @@ def index():
113167

114168

115169

170+
def getLink(dept_name):
171+
172+
173+
query = "Chemistry iit faculty name"
174+
175+
for j in search(query, tld="co.in", num=10, stop=10, pause=2):
176+
deptDict[dept_name]['list'].append(j)
177+
178+
116179

117180
def DepartmentHardCoded(dept_name):
118181

119182
data=[]
120183
table_body_arr=[]
121-
for link in deptDict[dept_name]:
184+
185+
186+
getLink(dept_name)
187+
print(deptDict[dept_name]['list'])
188+
for link in deptDict[dept_name]['list']:
122189

123190
faculty = requests.get(link, verify=False)
124191
# faculty = requests.get('https://www.me.iitb.ac.in/?q=full-time-faculty',verify=False)
@@ -272,5 +339,5 @@ def iitb_Mech():
272339

273340

274341
if __name__ == "__main__":
275-
app.run(debug=True,port="5000")
342+
app.run(debug=True,port="5000")
276343

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
85 Bytes
Binary file not shown.

requirements.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ Flask==1.1.2
33
requests==2.25.1
44
gunicorn
55
flask_session
6-
pandas
6+
pandas
7+
googlesearch-python

templates/index.html

+8-7
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
<div class="d-flex justify-content-center py-3 bg-primary text-light">
66
<h1>TATA Researcher Discovery Platform</h1>
77
</div>
8-
<div class="d-flex justify-content-center py-3">
8+
<div class=" justify-content-center p-3 m-auto w-50">
99
<form action="/" method="POST">
10-
<!-- <label for="dept_name">Choose a department:</label> -->
10+
<label for="dept_name">Choose a department:</label>
1111

12-
<!-- <select name="dept_name" id="dept_name" required>
12+
<select name="dept_name" id="dept_name" required>
1313

1414
{% if dept_name %}
1515
<option value='{{ dept_name }}'>
@@ -29,10 +29,11 @@ <h1>TATA Researcher Discovery Platform</h1>
2929
<option value="Mechanical Engineering">Mechanical Engineering</option>
3030
<option value="Civil Engineering">Civil Engineering</option>
3131
<option value="Biosciences and Bioengineering">Biosciences and Bioengineering</option>
32-
</select> -->
33-
<!-- <br><br>
34-
<input type="submit" name="submit" value="Submit" class="bg-success py-1 px-3 text-white rounded-pill border-0"> -->
35-
32+
</select>
33+
<br><br>
34+
<input type="submit" name="submit" value="Submit" class="bg-success py-1 px-3 text-white rounded-pill border-0">
35+
</form>
36+
<form action="/" method="POST">
3637
<div class="input-group mt-5 ">
3738
<input type="text" class="form-control" placeholder="Research Topic" aria-label="Research Topic" name="research_name" aria-describedby="button-addon2">
3839
<div class="input-group-append">

0 commit comments

Comments
 (0)