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

Add Configuration for Proxies #20

Merged
merged 7 commits into from
Aug 16, 2021

Conversation

lukaspanni
Copy link
Contributor

Changes

Added general configuration, currently used to configure proxies for requests.
All methods using requests.HTTP-METHOD now have an additional optional paramter to provide a proxy-config.
If no parameter is provided try to use a optional class-wide proxy-configuration.
If this fails a module-wide Config-Object module_config will be used.
This will make it easy to provide a global config but also to change proxies for every call.
deutschland.Bundesanzeiger uses requests.Session and therefore the proxy configuration is set for the whole session.

Example Code

from deutschland import Geo, Config, module_config

# set proxies in modue-wide config
module_config.set_proxy('http://10.10.1.10:3128', 'https://10.10.1.10:1080')


# class-wide config
local_config = Config({'http': 'http://10.10.1.10:3128', 'https': 'https://10.10.1.10:1080'})
geo = Geo(local_config)    # Overwrite global config and use local_config for all requests
...
# proxies only for the next call
proxies = {'http': 'http://10.10.1.10:3128', 'https': 'https://10.10.1.10:1080'}
data = geo.fetch([52.50876180448243, 13.359631043007212], 
                          [52.530116236589244, 13.426532801586827],
                          proxies)
Addressed Issues

@LilithWittmann LilithWittmann merged commit 4667874 into bundesAPI:main Aug 16, 2021
@lukaspanni lukaspanni deleted the config-proxies branch October 15, 2021 14:58
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

Successfully merging this pull request may close these issues.

paranoia mode: requests' proxy support
2 participants