fabiobatalha / crossrefapi

A python library that implements the Crossref API.
BSD 2-Clause "Simplified" License
265 stars 44 forks source link

get metadata of a certain paper #23

Closed CNGaoWenbo closed 4 years ago

CNGaoWenbo commented 4 years ago

I have known the exact title of a paper, how can I print metadata, like author name? (My plan is getting information automatically of more than 80 papers which I only know titles) Anyone have some ideas?

CNGaoWenbo commented 4 years ago

my codes is below, and it prints lots of url instead of the url of the certain paper for title in title_list: w1 = works.query(bibliographic=title) for item in w1: print(item['URL'])

fabiobatalha commented 4 years ago

@CNGaoWenbo

The results of a query by title are not deterministic. Even you have the exact title of a paper, several other articles may have a similar title and the results of the Crossref API don't have the compromise to delivery records that match exactly with a given title.

It means Crossref may delivery more then only one article for each query and they may not have any relation with the desired article.

Even though, lets say you will always have your desired articles in the very beginning of a list of matched articles.

Thinking on that, you may grab the first result and ignore the other retrieved documents. (I don't recommend to use this approach), the code is below:

In [16]: from crossref.restful import Works                                                                                                                                                                        

In [17]: works = Works()                                                                                                                                                                                           

In [18]: for item in works.query(bibliographic='Vers une théorisation du vécu des patients et de leurs proches à la suite d’interventions de crise à domicile'): 
    ...:     authors = item.get('author', []) 
    ...:     break 
    ...:                                                                                                                                                                                                           

In [19]: authors                                                                                                                                                                                                   
Out[19]: 
[{'given': 'John W.',
  'family': 'Kasckow',
  'sequence': 'first',
  'affiliation': []},
 {'given': 'Somaia',
  'family': 'Mohamed',
  'sequence': 'additional',
  'affiliation': []},
 {'given': 'Arthur',
  'family': 'Thallasinos',
  'sequence': 'additional',
  'affiliation': []},
 {'given': 'Brendan',
  'family': 'Carroll',
  'sequence': 'additional',
  'affiliation': []},
 {'given': 'Sidney',
  'family': 'Zisook',
  'sequence': 'additional',
  'affiliation': []},
 {'given': 'Dilip V.',
  'family': 'Jeste',
  'sequence': 'additional',
  'affiliation': []}]
CNGaoWenbo commented 4 years ago

@fabiobatalha I tried but the first one is still not what I want. It is merely another paper, and its title only includes one word from my research title. I add an author name to narrow down the results but do not work either.

fabiobatalha commented 4 years ago

Hello @CNGaoWenbo

This library is just an interface for the Crossref API. This request should be made in the Crossref API repository.

https://github.com/CrossRef/rest-api-doc/issues