Skip to content

Commit

Permalink
crossrefutils: urlencode encoding
Browse files Browse the repository at this point in the history
* Correctly urlencodes the query sent to CrossRef in order to
  retrieve information about a given DOI.
  (closes #3503)

Co-authored-by: Theodoropoulos Theodoros <[email protected]>
Co-authored-by: Chokri Ben Romdhane <[email protected]>
Signed-off-by: Samuele Kaplun <[email protected]>
  • Loading branch information
3 people committed Sep 22, 2015
1 parent dde5aee commit b3d2a94
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions modules/miscutil/lib/crossrefutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,18 @@ def get_marcxml_for_doi(doi):
doi = doi.strip()

# Getting the data from external source
url = "http://www.crossref.org/openurl/?pid=" + CFG_CROSSREF_USERNAME \
+ ":" + CFG_CROSSREF_PASSWORD + "&noredirect=tru&id=doi:" + doi

if CFG_CROSSREF_PASSWORD:
pid = '%s:%s' % (CFG_CROSSREF_USERNAME, CFG_CROSSREF_PASSWORD)
else:
pid = CFG_CROSSREF_USERNAME

query = urllib.urlencode({
'pid': pid,
'noredirect': 'tru',
'id': 'doi:%s' % doi})

url = "http://www.crossref.org/openurl/?" + query
request = urllib2.Request(url)
response = CROSSREF_OPENER.open(request)
header = response.info().getheader('Content-Type')
Expand Down

0 comments on commit b3d2a94

Please sign in to comment.