-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathQueryFunction.py
More file actions
35 lines (31 loc) · 1.19 KB
/
Copy pathQueryFunction.py
File metadata and controls
35 lines (31 loc) · 1.19 KB
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
from serpapi import GoogleSearch
def queryFunction(title, author):
Institutes = {}
string = '+'.join(str.split(title)) + "+" + '+'.join(str.split(author))
params = {
"engine": "google_scholar",
"q": string,
"api_key": "255dc7fe9dd992e9626160a1d48557435eacc85f8445f9bbf0d624142d9cfd8d"
}
search = GoogleSearch(params)
results = search.get_dict()
try:
Author_Ids = results['organic_results'][0]['publication_info']['authors']
for each in Author_Ids:
intermediate = {}
params = {
"engine": "google_scholar_author",
"author_id": each['author_id'],
"api_key": "255dc7fe9dd992e9626160a1d48557435eacc85f8445f9bbf0d624142d9cfd8d"
}
search = GoogleSearch(params)
results = search.get_dict()
try:
intermediate['name'] = each['name']
intermediate['affiliations'] = results['author']['affiliations']
Institutes[each['author_id']] = intermediate
return Institutes
except KeyError:
pass
except KeyError:
pass