In [15]:
'''
Important requires https://github.com/andycasey/ads

Getting Started

You'll need an API key from NASA ADS labs. Sign up for the newest version of ADS search here, then you can apply for API access by filling out this form.

When you get your API key, save it to a file called ~/.ads/dev_key or save it as an environment variable named ADS_DEV_KEY

From a terminal type pip install ads (or if you must, use easy_install ads)
'''
import ads
import cPickle as pickle 
import urllib

In [44]:
#Query ADS see https://github.com/andycasey/ads for the api 
query = ads.query("10.1093/mnras/stu129", database='astronomy', rows=1)

#Make a list of formated dictionaries to send to the pickle file
papers = []
paper_dicts = []
count = 0
for paper in query:
    dct = {'authors':paper.author, 'first_author_affiliation':paper.aff[0],
                        'number_of_citations':paper.citation_count, 'title':paper.title, 
                        'keywords':paper.keyword, 'arXiv_cat':u"None" 
            }
 
    arXiv_id = u'None'
    for j in paper.identifier:        
        if 'arXiv:' in j:
            arXiv_id = j.strip('arXiv:')
    
    if arXiv_id != u'None':
        url = 'http://export.arxiv.org/api/query?search_query={}'.format(arXiv_id)
        data = urllib.urlopen(url).readlines()
        #print data
        for i in data : 
            if 'category term=' in i :
                #print i
                arXiv_id = i.split()[1].strip("term=\"")
    
    print arXiv_id
    dct['arXiv_cat'] = arXiv_id
    print dct['arXiv_cat']
      
    paper_dicts.append(dct)
    papers.append(paper) 
        
#We can pickle that! 
#output = file('papers.pkl', 'w')
#pickle.dump(paper_dicts, output)
#output.close()


astro-ph.CO
astro-ph.CO

In [45]:
print paper_dicts


[{'arXiv_cat': 'astro-ph.CO', 'number_of_citations': 2, 'title': [u'Known unknowns of dark matter annihilation over cosmic time'], 'first_author_affiliation': u'School of Physics (David Caro Building), University of Melbourne, Victoria 3010, Australia; ARC Centre of Excellence for All-sky Astrophysics (CAASTRO), The University of Sydney, NSW 2006, Australia; ARC Centre of Excellence for Particle Physics at Terascale (CoEPP), School of Physics, The University of Melbourne, Victoria 3010, Australia', 'authors': [u'Mack, Katherine J.'], 'keywords': [u'galaxies: formation', u'dark matter', u'large-scale structure of Universe', u'Astrophysics - Cosmology and Extragalactic Astrophysics']}]

In [41]:
print papers[0]


<Ravignani  & Supanitsky 2015, 2015APh....65....1R>

In [ ]:


In [29]:
bob


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-29-e01096b9ffe3> in <module>()
----> 1 bob

NameError: name 'bob' is not defined

In [53]:
query = ads.query("Morehead, Robert C.", database='astronomy', sort='cited', rows=20)
for paper in query:
    print paper.citation_count, paper.title[0]


293 A closely packed system of low-mass, low-density planets transiting Kepler-11
286 Planet Occurrence within 0.25 AU of Solar-type Stars from Kepler
241 Kepler's First Rocky Planet: Kepler-10b
213 Architecture and Dynamics of Kepler's Candidate Multiple Transiting Planet Systems
198 Kepler-9: A System of Multiple Planets Transiting a Sun-Like Star, Confirmed by Timing Variations
184 The physics of double layers and their role in astrophysics.
110 Architecture of Kepler's Multi-transiting Systems. II. New Investigations with Twice as Many Candidates
101 Biogeochemical cycling in an organic-rich coastal marine basin—I. Methane sediment-water exchange processes
99 Almost All of Kepler's Multiple-planet Candidates Are Planets
56 Planetary Candidates Observed by Kepler IV: Planet Sample from Q1-Q8 (22 Months)
53 The Distribution of Transit Durations for Kepler Planet Candidates and Implications for Their Orbital Eccentricities
52 Transit timing observations from Kepler - VII. Confirmation of 27 planets in 13 multiplanet systems via transit timing variations and orbital stability
47 Five Kepler Target Stars That Show Multiple Transiting Exoplanet Candidates
46 Transit Timing Observations from Kepler. II. Confirmation of Two Multiplanet Systems via a Non-parametric Correlation Analysis
35 Mean Absolute Magnitudes of Carbon Stars and Related Objects
27 On the advancements of conformal transformations and their associated symmetries in geometry and theoretical physics
25 Multifrequency VLA observations of 3C 388: evidence for an intermittent jet ?
22 A mass balance of <SUP>13</SUP>C and <SUP>12</SUP>C in an organic-rich methane-producing marine sediment
20 A large metabolic carbon contribution to the δ <SUP>13</SUP>C record in marine aragonitic bivalve shells
19 Constraining the false positive rate for Kepler planet candidates with multicolour photometry from the GTC

In [ ]: