Line | |
---|
1 | # Program to get data from CrossRef, and OpenAlex formatted in a nice JSON file.
|
---|
2 |
|
---|
3 | # Crossref API library
|
---|
4 | from habanero import Crossref
|
---|
5 |
|
---|
6 | # diophila seems to work best
|
---|
7 | from diophila import OpenAlex
|
---|
8 |
|
---|
9 | # Default JSON library
|
---|
10 | import json
|
---|
11 |
|
---|
12 | # For command line interface
|
---|
13 | import sys, getopt
|
---|
14 |
|
---|
15 | NUMBER_TO_GET = 100
|
---|
16 | MAIL_ADDRESS = "[email protected]"
|
---|
17 |
|
---|
18 | def 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 |
|
---|
39 | if __name__ == "__main__":
|
---|
40 | main(sys.argv) |
---|
Note:
See
TracBrowser
for help on using the repository browser.