|
1 | | -from scholarly import scholarly |
2 | | -import jsonpickle |
3 | | -import json |
4 | | -from datetime import datetime |
5 | | -import os |
6 | | - |
7 | | -author: dict = scholarly.search_author_id(os.environ['GOOGLE_SCHOLAR_ID']) |
8 | | -scholarly.fill(author, sections=['basics', 'indices', 'counts', 'publications']) |
9 | | -name = author['name'] |
10 | | -author['updated'] = str(datetime.now()) |
11 | | -author['publications'] = {v['author_pub_id']:v for v in author['publications']} |
12 | | -print(json.dumps(author, indent=2)) |
13 | | -os.makedirs('results', exist_ok=True) |
14 | | -with open(f'results/gs_data.json', 'w') as outfile: |
15 | | - json.dump(author, outfile, ensure_ascii=False) |
16 | | - |
17 | | -shieldio_data = { |
18 | | - "schemaVersion": 1, |
19 | | - "label": "citations", |
20 | | - "message": f"{author['citedby']}", |
21 | | -} |
22 | | -with open(f'results/gs_data_shieldsio.json', 'w') as outfile: |
23 | | - json.dump(shieldio_data, outfile, ensure_ascii=False) |
| 1 | +from scholarly import scholarly, ProxyGenerator |
| 2 | +import jsonpickle |
| 3 | +import json |
| 4 | +from datetime import datetime |
| 5 | +import os |
| 6 | + |
| 7 | +# Setup proxy |
| 8 | +pg = ProxyGenerator() |
| 9 | +pg.FreeProxies() # Use free rotating proxies |
| 10 | +scholarly.use_proxy(pg) |
| 11 | + |
| 12 | +author: dict = scholarly.search_author_id(os.environ['GOOGLE_SCHOLAR_ID']) |
| 13 | +scholarly.fill(author, sections=['basics', 'indices', 'counts', 'publications']) |
| 14 | +name = author['name'] |
| 15 | +author['updated'] = str(datetime.now()) |
| 16 | +author['publications'] = {v['author_pub_id']:v for v in author['publications']} |
| 17 | +print(json.dumps(author, indent=2)) |
| 18 | +os.makedirs('results', exist_ok=True) |
| 19 | +with open(f'results/gs_data.json', 'w') as outfile: |
| 20 | + json.dump(author, outfile, ensure_ascii=False) |
| 21 | + |
| 22 | +shieldio_data = { |
| 23 | + "schemaVersion": 1, |
| 24 | + "label": "citations", |
| 25 | + "message": f"{author['citedby']}", |
| 26 | +} |
| 27 | +with open(f'results/gs_data_shieldsio.json', 'w') as outfile: |
| 28 | + json.dump(shieldio_data, outfile, ensure_ascii=False) |
0 commit comments