Last change
on this file since 38791 was 38791, checked in by jc550, 4 months ago |
add comments adding context to functions that require it
|
File size:
1.1 KB
|
Line | |
---|
1 | # Program to get data from CrossRef, and OpenAlex formatted in a nice JSON file.
|
---|
2 | # Was supposed to be a replacement for another function pre-mongo.
|
---|
3 |
|
---|
4 | # Crossref API library
|
---|
5 | from habanero import Crossref
|
---|
6 |
|
---|
7 | # diophila seems to work best
|
---|
8 | from diophila import OpenAlex
|
---|
9 |
|
---|
10 | # Default JSON library
|
---|
11 | import json
|
---|
12 |
|
---|
13 | # For command line interface
|
---|
14 | import sys, getopt
|
---|
15 |
|
---|
16 | NUMBER_TO_GET = 100
|
---|
17 | MAIL_ADDRESS = "[email protected]"
|
---|
18 |
|
---|
19 | def main(argv):
|
---|
20 | opts, args = getopt.getopt(argv, "h")
|
---|
21 | if len(opts) == 0 or opts[0] == "-h":
|
---|
22 | print("USAGE: " + argv[0] + " <outputfile>")
|
---|
23 | sys.exit()
|
---|
24 |
|
---|
25 | outputFile = open(argv[1], "wt", encoding="utf-8")
|
---|
26 |
|
---|
27 | # Prepare the clients to retrieve data
|
---|
28 | crossrefClient = Crossref(mailto = MAIL_ADDRESS)
|
---|
29 | openAlexClient = OpenAlex(MAIL_ADDRESS)
|
---|
30 |
|
---|
31 | # Generate and send query to CrossRef (Limited Query = 100)
|
---|
32 | query = cr.works(cursor = "*", cursor_max = 5000, filter = {'from_pub_date': '2023', 'type' : ['journal-article', 'proceedings-article', 'book-chapter']})
|
---|
33 |
|
---|
34 |
|
---|
35 | # Unfinished and not worth continuing
|
---|
36 |
|
---|
37 | if __name__ == "__main__":
|
---|
38 | main(sys.argv) |
---|
Note:
See
TracBrowser
for help on using the repository browser.