Skip to content

Instantly share code, notes, and snippets.

@schluppeck
Last active August 29, 2015 14:20
Show Gist options
  • Save schluppeck/df7806414a91238cda77 to your computer and use it in GitHub Desktop.
Save schluppeck/df7806414a91238cda77 to your computer and use it in GitHub Desktop.
download pubmed citations into JSON file using unix cURL
#!/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