alvarobartt / investpy

Financial Data Extraction from Investing.com with Python
https://investpy.readthedocs.io/
MIT License
1.64k stars 377 forks source link

support for proxy #178

Open akasolace opened 4 years ago

akasolace commented 4 years ago

I have a quick hack I need to apply to used investpy behind corporate proxy. It is as simple as adding an argument header_proxy to the relevant functions and update the headers before the request call. Something like:

def get_currency_cross_information(currency_cross, headers_proxy, as_json=False):
    ...
   head.update(header_proxy)
   ....

Would you accept a PR for this.

lefig commented 4 years ago

I second this request following on from the previous issues I raised regarding IP address blocking.

Our workaround is to pass an optional proxy parameter to a an API call as above:

def technical_indicators(name, country, product_type, interval='daily', proxy=None):

......................

Then a check is made for None before passing to the requests call(if not None).

We cycle through proxy addresses but there is no need to do so for Headers as this is already done by investpy.

So by placing the responsibility on the external client to pass the proxy makes more sense than investpy do it. A solution is needed because at some point your IP address will be blocked by Investing as they confirmed to me. They suggested infact using the Proxy.

lefig commented 4 years ago

Hi there,

Have you given this further thought?

Passing in of an optional proxy value to include the requests call?

Thanks

Fig