Skip to content

Instantly share code, notes, and snippets.

@tpoisot
Created January 17, 2014 00:56
Show Gist options
  • Save tpoisot/8466530 to your computer and use it in GitHub Desktop.
Save tpoisot/8466530 to your computer and use it in GitHub Desktop.
I've invented a way NOT to get a citation from a DOI using the crossref API
#! /usr/bin/python2
import requests as re
doi = "10.1002/ece3.508"
base = "http://dx.doi.org/"
url = base + doi
#headers = {'Accept': 'text/bibliography', 'style': 'ecology-letters'}
ref = re.get(url)
print ref.text
@sckott
Copy link

sckott commented Jan 17, 2014

Weird, worked for a different DOI using accept header

@sckott
Copy link

sckott commented Jan 17, 2014

This works for me

import requests as re

doi = "10.1371/journal.pone.0083953"

base = "http://dx.doi.org/"

url = base + doi

headers = {"Accept": "text/bibliography; style=mla; locale=fr-FR"}

ref = re.get(url, headers=headers)

print ref.text
Nifong, James C. et al. « Animal-Borne Imaging Reveals Novel Insights into the Foraging Behaviors and Diel Activity of a Large-Bodied Apex Predator, the American Alligator (Alligator mississippiensis) ». éd par. Christopher D. Marshall. PLoS ONE 9.1 (2014): e83953.

@sckott
Copy link

sckott commented Jan 17, 2014

Or json return with:

headers = {"Accept": "application/citeproc+json"}
{"volume":"3","issue":"4","DOI":"10.1002/ece3.508","URL":"http://dx.doi.org/10.1002/ece3.508","title":"High-Throughput Sequencing: A Roadmap Toward Community Ecology","container-title":"Ecology and Evolution","publisher":"Wiley Blackwell (John Wiley & Sons)","issued":{"date-parts":[[2013,4,11]]},"author":[{"family":"Poisot","given":"Timothée"},{"family":"Péquin","given":"Bérangère"},{"family":"Gravel","given":"Dominique"}],"editor":[],"page":"1125-1139","type":"article-journal"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment