Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can identify to crossref? #63

Closed
brandonStell opened this issue Sep 30, 2017 · 13 comments
Closed

Can identify to crossref? #63

brandonStell opened this issue Sep 30, 2017 · 13 comments
Milestone

Comments

@brandonStell
Copy link

https://github.com/CrossRef/rest-api-doc#etiquette

@sckott
Copy link
Owner

sckott commented Sep 30, 2017

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

@brandonStell
Copy link
Author

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.

@sckott
Copy link
Owner

sckott commented Sep 30, 2017

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

@brandonStell
Copy link
Author

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.

@sckott
Copy link
Owner

sckott commented Sep 30, 2017

okay, i'll look into it

@brandonStell
Copy link
Author

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

@sckott
Copy link
Owner

sckott commented Oct 6, 2017

@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

@sckott
Copy link
Owner

sckott commented Oct 9, 2017

@brandonStell thoughts on my last comment?

@brandonStell
Copy link
Author

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...)

@sckott
Copy link
Owner

sckott commented Oct 11, 2017

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

@brandonStell
Copy link
Author

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

@sckott
Copy link
Owner

sckott commented Oct 15, 2017

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

can look into adding option to set that

@sckott sckott added this to the v0.6 milestone Oct 15, 2017
@sckott
Copy link
Owner

sckott commented Oct 16, 2017

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

@sckott sckott closed this as completed Oct 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants