sckott / habanero

client for Crossref search API

Home Page:https://habanero.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can identify to crossref?

brandonStell opened this issue · comments

i have no idea what you're asking, please clarify

Sorry about that. I agree that it was completely incomprehensible. Thanks for taking the time to get back to me.

is it possible to

Specify a User-Agent header that properly identifies your script or tool and that provides a means of contacting you via email using "mailto:". For example: GroovyBib/1.1 (https://example.org/GroovyBib/; mailto:GroovyBib@example.org) BasedOnFunkyLib/1.4.

we do send a user agent header in every request, try this:

import requests
import logging
import httplib as http_client
http_client.HTTPConnection.debuglevel = 1
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True
from habanero import Crossref
cr = Crossref()
x = cr.works(query = "ecology")
# gives in request headers
GET /works?query=ecology HTTP/1.1
Host: api.crossref.org
Connection: keep-alive
Accept-Encoding: gzip, deflate
Accept: */*
User-Agent: python-requests/2.18.1 habanero/0.5.0.1
X-USER-AGENT: python-requests/2.18.1 habanero/0.5.0.1

I imagine you want to set your own user agent string though, correct? if so, I can probably modify Crossref class to allow to set a user agent string

I'd like to be able to set a mailto:
If I hammer their servers I'd like to give them the opportunity to contact me.

okay, i'll look into it

actually...
this seems to work and probably solves my issue:
crossrefJson = cr.works(query_title ='Cancer', mailto='email@address.com')

@brandonStell are you sure that's working? looking at code, looks like we setup **kwargs to be used for field queries only with the works/members/etc. functions

@brandonStell thoughts on my last comment?

Sorry for the slow response. Unfortunately now I can't remember why I thought it was working (perhaps because it didn't throw an error...)

yeah, i wouldn't think it would throw an error

from my understanding of the code, i don't think what you did should work, can you try again with the verbose printing from #63 (comment) and show me what you get

DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.crossref.org
DEBUG:urllib3.connectionpool:https://api.crossref.org:443 "GET /works?query.title=Cancer HTTP/1.1" 200 208922

right, so looks like it doesn't work to pass in email.

can look into adding option to set that

@brandonStell sorted out via #68 - try again after reinstalling from github, will push new version to pypi soon