-
Notifications
You must be signed in to change notification settings - Fork 30
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
Any way to set/add to user agent string? #84
Comments
thanks for your question @hmpf we currently send with each request the following UA headers (package versions change obviously)
Would you want to add to that string or change it completely? |
Good question. If the existing setting can be both read and changed (allowing changing it completely and adding to it) I think you'll never get this question again :) I need just to add to the end, my UA, link to site, and a mailto. I'll be hitting crossref once a week or so, is the current plan. (The actual mailto wil lhave to be a setting on my side though as it's a microservice that no doubt will end up running in multiple places.) |
i'll have a look. Not sure right now what it will look like but it'll be possible for sure |
@hmpf reinstall from branch # set an additional user-agent string
x = Crossref(ua_string = "foo bar")
x
x.works(ids = '10.1371/journal.pone.0033693')
## unset the additional user-agent string
x = Crossref()
x.works(ids = '10.1371/journal.pone.0033693') do verbose logging to see the request headers 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 |
The pip-url was wrong, this is the correct one: |
For python 3, replace Tested. This covers my needs! |
woops, thx for the url fix - forgot to fix the copy/paste. glad it works. |
I know
mailto
can be set, but I hope to use this library as part of a service that fetches from many APIs and would like the same or same-ish user agent everywhere.The text was updated successfully, but these errors were encountered: