From 130fe59cb378e7f37e522d82e11e92a890d5509c Mon Sep 17 00:00:00 2001 From: Peter Teuben Date: Tue, 9 Feb 2021 16:30:43 -0500 Subject: [PATCH] drafted first version --- ads/ads1.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 ads/ads1.py diff --git a/ads/ads1.py b/ads/ads1.py new file mode 100755 index 0000000..cbcba7e --- /dev/null +++ b/ads/ads1.py @@ -0,0 +1,40 @@ +#! /usr/bin/env python +# +# https://github.com/adsabs/ads-examples +# https://ads.readthedocs.io/en/latest/ +# https://github.com/adsabs/adsabs-dev-api curl +# Needs: ~/.ads/dev_key +# + +import os +import sys + +# - sandbox doesn't seem to work (jan 2021) +#import ads.sandbox as ads +import ads + + +# listing with code names +arg1 = sys.argv[1] + +codes = open(arg1).readlines() +for code in codes: + code = code.strip() + if code[0] == '#': + continue + + print("# CODE:",code) + + # lazy loading (expensive) + #q = ads.SearchQuery(full=code, sort=year) + + # loading with fields ahead of time + q = ads.SearchQuery(full=code, fl=['title','first_author','year','citation_count','bibcode'],sort='year', rows=10) + + n1 = 0 + for paper in q: + print(paper.year, paper.citation_count, paper.bibcode, paper.first_author, paper.title) + n1 = n1 + 1 + + q1=q.response.get_ratelimits() + print('# %d %s\n' % (n1,q1['remaining']))