alvarobartt / investpy

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

ERR#0004: data retrieval error while scraping. #330

Closed victorbennini closed 3 years ago

victorbennini commented 3 years ago

Hi everyone,

I've been working on a deep learning research project involving investpy to collect the data. It used to work just fine on a Google Colab code. It's a pretty standard code. But all of a sudden yesterday, the code raises this error everytime : RuntimeError: ERR#0004: data retrieval error while scraping.

Here's an example of functions that don't work anymore : investpy.get_stock_historical_data(stock='AAPL', country='United States', from_date='01/01/2010', to_date='01/01/2020') investpy.get_index_historical_data(index=name, country=country, from_date='01/01/1990', to_date='30/10/2020', interval='Daily')[["Close"]]

for any function other than investpy.indices.get_indices(), the error is raised.

I tried :

Can anyone help me with this ?

nhlsm commented 3 years ago

Same problem.

Invest.com response with header "... Content-Encoding: br ..." But lxml.html.fromstring() can't decode "br" ( Brotli )

WORKAROUND Fixing request header's "Accept-Encoding" to "gzip, deflate", works well. ( I tested copy and fix installed package source.
It seems that normal correction is necessary. )

danilogalisteu commented 3 years ago

See #327 and #328.

st356907 commented 3 years ago

Seems like there is a maintenance break on the website. I recommend you to take a break too. image

alvarobartt commented 3 years ago

Thanks a lot to everyone, especially to @nhlsm and to @danilogalisteu, as the solution they proposed works like a charm. The tests are already running, but once I check everything is OK (besides the Investing.com issues that have nothing to do with investpy), I'll upload the new release mentioning everyone involved in solving it! :fire: Thanks for this awesome support and sorry for my delayed response.

alvarobartt commented 3 years ago

You can install the new-fixed version as it follows:

pip install investpy==1.0.5

Sorry for the inconvenience, seems that Investing.com is applying a lot of changes and under maintenance... Everyone thank both @danilogalisteu and @nhlsm for their awesome support! 👍🏻

alvarobartt commented 3 years ago

Feel free to drop some comments here https://github.com/alvarobartt/investpy/discussions/334 and more information if applicable, such as the IDs of the solved issues and so on, so that I can include all the information into the Release Notes! :hugs: Thank you!

mrkgoh commented 3 years ago

Thank you everyone. I just had this problem this morning and glad that there already is a solution. Thanks @alvarobartt