1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
| """An example program that uses the elsapy module"""
from elsapy.elsclient import ElsClient from elsapy.elsprofile import ElsAuthor, ElsAffil from elsapy.elsdoc import FullDoc, AbsDoc from elsapy.elssearch import ElsSearch import json
con_file = open("config.json") config = json.load(con_file) con_file.close()
client = ElsClient(config['apikey'])
my_auth = ElsAuthor( uri = 'https://api.elsevier.com/content/author/author_id/7004367821')
if my_auth.read(client): print ("my_auth.full_name: ", my_auth.full_name) my_auth.write() else: print ("Read author failed.")
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.")
scp_doc = AbsDoc(scp_id = 84872135457) if scp_doc.read(client): print ("scp_doc.title: ", scp_doc.title) scp_doc.write() else: print ("Read document failed.")
pii_doc = FullDoc(sd_pii = 'S1674927814000082') if pii_doc.read(client): print ("pii_doc.title: ", pii_doc.title) pii_doc.write() else: print ("Read document failed.")
doi_doc = FullDoc(doi = '10.1016/S1525-1578(10)60571-5') if doi_doc.read(client): print ("doi_doc.title: ", doi_doc.title) doi_doc.write() else: print ("Read document failed.")
print ("Load documents (Y/N)?") s = input('--> ')
if (s == "y" or s == "Y"):
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.")
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.")
auth_srch = ElsSearch('authlast(keuskamp)','author') auth_srch.execute(client) print ("auth_srch has", len(auth_srch.results), "results.")
aff_srch = ElsSearch('affil(amsterdam)','affiliation') aff_srch.execute(client) print ("aff_srch has", len(aff_srch.results), "results.")
doc_srch = ElsSearch("AFFIL(dartmouth) AND AUTHOR-NAME(lewis) AND PUBYEAR > 2011",'scopus') doc_srch.execute(client, get_all = True) print ("doc_srch has", len(doc_srch.results), "results.")
doc_srch = ElsSearch("star trek vs star wars",'sciencedirect') doc_srch.execute(client, get_all = False) print ("doc_srch has", len(doc_srch.results), "results.")
|