requests-html
requests-html copied to clipboard
Proxies parameter in BaseSession __init__
Due to #345 I noticed that user can't use proxy. In requests proxy is used as following requests.get(URL, proxies={})
so we need to have proxies
attribute in BaseSession
.
So now requests-html support the use of proxy also when using the render method?
How to specify?
Yes with this fix, render()
also uses the proxy settings. Plus, proxies can be configured at the HTMLSession()
level so you don't have to set them per request.
Note that you'll still need to configure browser_args
with --proxy-server
option to get puppeteer to use the proxy settings. This PR fixes the request session side of things which we also need.
Could we get this PR merged please?
Possible to get this merged?
Doesn't work
proxy_url = f"http://{proxy_config.username}:{proxy_config.password}@{proxy_config.host}:{proxy_config.port}"
proxies = {'http': proxy_url, 'https': proxy_url}
js_session = HTMLSession(browser_args=[f"--proxy-server={proxy_config.host}:{proxy_config.port}"])
response = js_session.get(url="https://vk.com/audio?block=chart", proxies=proxies)
response.html.render()
In this example program stucking on response.html.render()
line