Last active
August 29, 2015 14:20
-
-
Save schluppeck/df7806414a91238cda77 to your computer and use it in GitHub Desktop.
download pubmed citations into JSON file using unix cURL
This file contains hidden or 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
#!/bin/bash | |
# | |
# downloading pubmed data into json files | |
# | |
# used curl --help and stackoverflow for inspiration. also check out the posts here: | |
# http://superuser.com/questions/149329/what-is-the-curl-command-line-syntax-to-do-a-post-request | |
# define some variables - change as appropriate | |
author="schluppeck-d" | |
# pubmed search cgi is located here | |
url="http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi" | |
database="db=pubmed" # which database to use | |
retmode="retmode=json" # file format to return | |
term="term=(${author}[AU])" # search term | |
outfile="${author}.json" # name of output file | |
# make the command | |
cmd="curl --data \"&${database}&${retmode}&${term}\" -# --header \"Content-Type:application/json\" --output ${outfile} ${url} " | |
# display | |
echo "using cURL to download json data from ${url}" | |
# echo ${cmd} | |
# and run | |
$($cmd) | |
echo "done!" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment