def auth_id_query(auth_id): my_auth = ElsAuthor(uri='https://api.elsevier.com/content/author/author_id/%s' % (auth_id)) # Read author data, then write to disk if my_auth.read(client): try: return my_auth.data['author-profile']['affiliation-history']['affiliation'] except KeyError: print("Query results for '%s' were not structured correctly." % (auth_id)) # print(my_auth.data['author-profile']) else: print ("Read author failed.")
def readElsevierAuthor(self, authorID='7004367821'): ## Author example # Initialize author with uri my_auth = ElsAuthor( uri='https://api.elsevier.com/content/author/author_id/' + authorID) # Read author data, then write to disk if my_auth.read(self.client): print("my_auth.full_name: ", my_auth.full_name) my_auth.write() else: print("Read author failed.")
def initAuthor(author_id): # Initialize author with uri my_auth = ElsAuthor( uri='https://api.elsevier.com/content/author/author_id/{}'.format( author_id)) print('https://api.elsevier.com/content/author/author_id/{}'.format( author_id)) # Read author data, then write to disk if my_auth.read(client): print('OR AU-ID("{}” {})'.format( my_auth.data['author-profile']['preferred-name']['indexed-name'], author_id)) return my_auth.data['author-profile']['preferred-name']['indexed-name'] else: print("Read author failed.")
def get_author(author_id): """ Retrieves an author :param author_id: :param api_key: :return: """ logger.info(f'Retrieving author {author_id}') api_key = key_manager.get_key('author') client = elsclient.ElsClient(api_key) author = ElsAuthor(author_id=author_id) if not author.read(client): logger.error("[!]Read author failed: %s", author_id) author.data['_id'] = author.data['coredata']['dc:identifier'].split(':')[1] author.data['last_modified'] = datetime.now() return author.data
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 getInfoAboutTeacher(person): # Load configuration con_file = open(SCOPUS_CREDENTIAL_FILE) config = json.load(con_file) con_file.close() # Initialize client client = ElsClient(config['apikey']) client.inst_token = config['insttoken'] # Initialize author with uri my_auth = ElsAuthor( uri='https://api.elsevier.com/content/author/author_id/' + str(person.scopusId)) # Read author data, then write to disk if my_auth.read(client): return my_auth.data['coredata'] else: print("Read author failed.")
from requests import get # seguindo o método DRY vamos importar nossas rotinas do modulo fishbase # primeiro vamos incluir como import sys sys.path.append('./modules') #import fishbase #h = fishbase.host ## Author example # Initialize author with uri my_auth = ElsAuthor( uri = 'https://api.elsevier.com/content/author/author_id/7004367821') # Read author data, then write to disk if my_auth.read(client): print ("my_auth.full_name: ", my_auth.full_name) my_auth.write() else: print ("Read author failed.") ## Affiliation example # Initialize affiliation with ID as string my_aff = ElsAffil(affil_id = '60101411') if my_aff.read(client): print ("my_aff.name: ", my_aff.name) my_aff.write() else: print ("Read affiliation failed.") ## Scopus (Abtract) document example