Exemplo n.º 1
0
def get_author_by_id(client, author):
    author_data = {}

    my_auth = ElsAuthor(
        uri=f"https://api.elsevier.com/content/author/author_id/{author}")

    if my_auth.read(client):
        my_auth.read_metrics(client)
        my_auth.read_docs(client)

        field_str = ""
        field_list = []
        for area in my_auth.data['subject-areas']['subject-area']:
            field_str += f"{area['$']} | "
            field_list.append(area['$'])

        author_data['name'] = my_auth.full_name
        author_data['url'] = my_auth.data['coredata']['link'][0]['@href']
        author_data['h-index'] = my_auth.data['h-index']
        author_data['docs'] = my_auth.data['coredata']['document-count']
        author_data['cit'] = my_auth.data['coredata']['citation-count']
        author_data['fields'] = field_list
        author_data['pub-range'] = my_auth.data['author-profile'][
            'publication-range']
        try:
            author_data['affiliation'] = {
                'name':
                my_auth.data['author-profile']['affiliation-current']
                ['affiliation']['ip-doc']['preferred-name']['$'],
                'country':
                my_auth.data['author-profile']['affiliation-current']
                ['affiliation']['ip-doc']['address']['country'],
                'url':
                my_auth.data['author-profile']['affiliation-current']
                ['affiliation']['ip-doc']['org-URL']
            }
        except KeyError:
            author_data['affiliation'] = {'name': '', 'country': '', 'url': ''}

        # print(author_data)

        return author_data

    else:
        print("Read author failed.")
 def readAllDocsFromAuthor(self, authorID='7004367821'):
     ## Read all documents for example author, then write to disk
     my_auth = ElsAuthor(
         uri='https://api.elsevier.com/content/author/author_id/' +
         authorID)
     if my_auth.read_docs(self.client):
         print("my_auth.doc_list has " + str(len(my_auth.doc_list)) +
               " items.")
         my_auth.write_docs()
     else:
         print("Read docs for author failed.")
Exemplo n.º 3
0
    print ("doi_doc.title: ", doi_doc.title)
    doi_doc.write()   
else:
    print ("Read document failed.")


## Load list of documents from the API into affilation and author objects.
# Since a document list is retrieved for 25 entries at a time, this is
#  a potentially lenghty operation - hence the prompt.
print ("Load documents (Y/N)?")
s = input('--> ')

if (s == "y" or s == "Y"):

    ## Read all documents for example author, then write to disk
    if my_auth.read_docs(client):
        print ("my_auth.doc_list has " + str(len(my_auth.doc_list)) + " items.")
        my_auth.write_docs()
    else:
        print ("Read docs for author failed.")

    ## Read all documents for example affiliation, then write to disk
    if my_aff.read_docs(client):
        print ("my_aff.doc_list has " + str(len(my_aff.doc_list)) + " items.")
        my_aff.write_docs()
    else:
        print ("Read docs for affiliation failed.")

## Initialize author search object and execute search
auth_srch = ElsSearch('authlast(keuskamp)','author')
auth_srch.execute(client)