source: other-projects/metadata-encoding/py/using-api/getData.py@ 38773

Last change on this file since 38773 was 38773, checked in by jc550, 4 months ago

last batch of python to move

File size: 998 bytes
Line 
1# Program to get data from CrossRef, and OpenAlex formatted in a nice JSON file.
2
3# Crossref API library
4from habanero import Crossref
5
6# diophila seems to work best
7from diophila import OpenAlex
8
9# Default JSON library
10import json
11
12# For command line interface
13import sys, getopt
14
15NUMBER_TO_GET = 100
16MAIL_ADDRESS = "[email protected]"
17
18def main(argv):
19 opts, args = getopt.getopt(argv, "h")
20 if len(opts) == 0 or opts[0] == "-h":
21 print("USAGE: " + argv[0] + " <outputfile>")
22 sys.exit()
23
24 outputFile = open(argv[1], "wt", encoding="utf-8")
25
26 # Prepare the clients to retrieve data
27 crossrefClient = Crossref(mailto = MAIL_ADDRESS)
28 openAlexClient = OpenAlex(MAIL_ADDRESS)
29
30 # Generate and send query to CrossRef (Limited Query = 100)
31 query = cr.works(cursor = "*", cursor_max = 5000, filter = {'from_pub_date': '2023', 'type' : ['journal-article', 'proceedings-article', 'book-chapter']})
32
33
34
35
36
37
38
39if __name__ == "__main__":
40 main(sys.argv)
Note: See TracBrowser for help on using the repository browser.