-
-
Notifications
You must be signed in to change notification settings - Fork 431
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
Pass optional arguments to requests.get #282
Conversation
Hi! Thanks for the suggestion. Sounds like an interesting extension, though I think it would be more future-proof if we add a kwargs parameter specifically for requests. For example:
This way, if at any point in the future we want to expose / forward arguments to / of other libraries used by NP, we could easily do so using the above. |
It would be beneficial if users could pass optional arguments, such as authentication information and proxy configurations, to requests made by `NewsPlease.from_url` and `NewsPlease.from_urls`. This commit adds `**kwargs` to the above functions and passes them to `requests.get` in `SimpleCrawler._fetch_url`.
Thank you for your review. I added a commit so that the fetch functions now use |
Thanks a lot for the changes. I'll have to think about what to do with the other two parameters of request that are directly exposed (timeout and user_agent). Currently have a tendency towards removing them to have a clean interface. I'll get back to you soon regarding this. |
For cleaner consistency of the changes introduced by the PR, could you remove timeout and user_agent from the method signature as they would be set through the new parameter the PR introduces? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see previous comment
These parameters can now be passed via `request_args`. For more details, see fhamborg#282 (comment).
I've just added a commit to remove |
hi @jkawamoto thanks for the quick changes! could you change the name to requests_args (note the s as in the original library name)? other than that this looks good! edit: just noted that the function is called request, so this is actually fine. thank you! |
It would be beneficial if users could pass optional arguments, such as authentication information and proxy configurations, to requests made by
NewsPlease.from_url
andNewsPlease.from_urls
.This PR adds
**kwargs
to the above functions and passes them torequests.get
inSimpleCrawler._fetch_url
.With this change, users can add authentication information like this:
and also add proxy configurations like this:
Related to #234 and #254.