Skip to content

Commit

Permalink
drafted first version
Browse files Browse the repository at this point in the history
  • Loading branch information
teuben committed Feb 9, 2021
1 parent 892c763 commit 130fe59
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions ads/ads1.py
Original file line number Diff line number Diff line change
@@ -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']))

0 comments on commit 130fe59

Please sign in to comment.