-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathperson_info.py
76 lines (46 loc) · 1.8 KB
/
person_info.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import aiohttp
import asyncio
import bs4
import re
from pandas import read_excel
import time
from function import *
Link = "https://scholar.google.com/citations?hl=en&user=lB5LhOQAAAAJ"
async def fetch_all_data(url):
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
# name = url[to_cut:]
status = response.status
response = await response.text()
if status == 429:
print("too many request to server , error code : 429")
# if verbose:
# print(response, status)
soup = bs4.BeautifulSoup(response , 'html.parser')
name = soup.find("div" , {'id' : 'gsc_prf_in'}).get_text()
affiliation = soup.find("div" ,{'class' : 'gsc_prf_il'}).get_text()
email = soup.find("div" , {'id':'gsc_prf_ivh'}).get_text()
email = email[len("Verified email at "):]
img = soup.find("div" , {'id' : 'gsc_prf_pua'})
img_ = img.find("img")
img_link = "https://scholar.google.com"+str(img_["src"])
print('img' , img_link)
citations = soup.find("td" , {'class' :'gsc_rsb_std'}).get_text()
print("name_tag" , name)
print("affiliation" , affiliation)
print("email" , email)
print('citations' , citations)
def print_all_pages():
# f = init_file()
# pages = create_links(n)
tasks = []
loop = asyncio.new_event_loop()
try:
tasks.append(loop.create_task(fetch_all_data(Link)))
loop.run_until_complete(asyncio.wait(tasks))
except KeyboardInterrupt:
print("Program Terminated by User")
print("<---Bye--->")
loop.close()
# close_file(f)
print_all_pages()