Created
August 24, 2016 10:56
-
-
Save afandian/034de2645fbf7923580939b9d53197bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# pip3 install requests | |
import requests | |
ignore_prefix = len('http://id.crossref.org/prefix/') | |
cursor = "*" | |
prefixes = {} | |
works = True | |
while works: | |
message = requests.get("http://api.crossref.org/works", | |
params={"cursor": cursor, | |
"rows": 500, | |
"filter": "has-clinical-trial-number:true"}).json()['message'] | |
works = message['items'] | |
cursor = message['next-cursor'] | |
for work in works: | |
prefix = work['prefix'][ignore_prefix:] | |
prefixes[prefix] = prefixes.get(prefix,0) + 1 | |
total = 0 | |
for prefix, count in prefixes.items(): | |
prefix_owner = requests.get("http://api.crossref.org/prefixes/" + prefix).json()['message']['name'] | |
print("%s\t%s\t%d" % (prefix, prefix_owner, count)) | |
total += count | |
print("Total: %d" % total) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment