investpy
investpy copied to clipboard
ConnectionError: ERR#0015: error 403, try again later.
Code-
import investpy
df = investpy.get_stock_historical_data(stock='AAPL',
country='United States',
from_date='01/01/2010',
to_date='01/01/2020')
print(df.head())
Error-
ConnectionError Traceback (most recent call last)
[<ipython-input-4-f6f4235b7e47>](https://localhost:8080/#) in <module>
4 country='United States',
5 from_date='01/01/2010',
----> 6 to_date='01/01/2020')
7 print(df.head())
[/usr/local/lib/python3.7/dist-packages/investpy/stocks.py](https://localhost:8080/#) in get_stock_historical_data(stock, country, from_date, to_date, as_json, order, interval)
663 if req.status_code != 200:
664 raise ConnectionError(
--> 665 "ERR#0015: error " + str(req.status_code) + ", try again later."
666 )
667
ConnectionError: ERR#0015: error 403, try again later.
I've the same issue, from my investigation https://www.investing.com/instruments/HistoricalDataAjax seems to be discontinued!
I've the same issue.
Same issue, any update on this?
I have the same accion = 'AAPL' search_result = investpy.search_quotes(text=accion, products=['stocks'], countries=['united states'], n_results=1)
File "D:\Python39\lib\site-packages\investpy\search.py", line 127, in search_quotes raise ConnectionError(f"ERR#0015: error {req.status_code}, try again later.") ConnectionError: ERR#0015: error 403, try again later.
Same here.
/usr/local/lib/python3.7/dist-packages/investpy/stocks.py in get_stock_historical_data(stock, country, from_date, to_date, as_json, order, interval) 663 if req.status_code != 200: 664 raise ConnectionError( --> 665 "ERR#0015: error " + str(req.status_code) + ", try again later." 666 ) 667
ConnectionError: ERR#0015: error 403, try again later.
Same here. Did some research and it seems error 403 indicates that the server understands the request but refuses to authorize it.
You can still pull the economic calendar but everything else seems to be returning a 403.
Also confirming get_index_historical_data yields "ConnectionError: ERR#0015: error 403, try again later" (tried multiple US symbols) but econ calendar still works. Was working yesterday
Hi everyone! I've checked this issue and it seems that the internal API that Investing.com uses has changed without prior notice, as this is not an official implementation. Sorry for the inconvenience, this issue will be solved in the upcoming days, hopefully, today I'll push a patch to solve this, I'll share later on with you the branch where I'm working actively to solve this!
Both get_stock_recent_data
and get_stock_historical_data
are fixed in https://github.com/alvarobartt/investpy/tree/403-patch, I'll add the comments of the fix in an upcoming PR! In the meantime, you can install the latest investpy
version from 403-patch
branch as pip install git+https://github.com/alvarobartt/investpy@403-patch
Hi again everyone, feel free to track the progress of the patch at https://github.com/alvarobartt/investpy/pull/602 :hugs: I'd also appreciate some feedback from the ones testing it! So drop your feedback either here or in https://twitter.com/alvarobartt/status/1570661023262310402
Commodity historical data not working
investpy.get_commodity_historical_data
ConnectionError: ERR#0015: error 403, try again later.
Hi @alvarobartt , get_historcal_data
is working. get_index_historical_data
is not working.
``
Code-
df = investpy.get_index_historical_data(index="S&P 500",country="United States",from_date="01/01/2010",to_date="01/01/2022")
df
Error-
---------------------------------------------------------------------------
ConnectionError Traceback (most recent call last)
[<ipython-input-31-5e1d4758da05>](https://localhost:8080/#) in <module>
----> 1 df = investpy.get_index_historical_data(index="S&P 500",country="United States",from_date="01/01/2010",to_date="01/01/2022")
2 df
[/usr/local/lib/python3.7/dist-packages/investpy/indices.py](https://localhost:8080/#) in get_index_historical_data(index, country, from_date, to_date, as_json, order, interval)
648 if req.status_code != 200:
649 raise ConnectionError(
--> 650 "ERR#0015: error " + str(req.status_code) + ", try again later."
651 )
652
ConnectionError: ERR#0015: error 403, try again later.
Really Appreciate your efforts. Thank you so much.
Both
get_stock_recent_data
andget_stock_historical_data
are fixed in https://github.com/alvarobartt/investpy/tree/403-patch, I'll add the comments of the fix in an upcoming PR! In the meantime, you can install the latestinvestpy
version from403-patch
branch aspip install git+https://github.com/alvarobartt/investpy@403-patch
Could anyone help me on how to install the patch? Python gives me an error. Thank you!
Could anyone help me on how to install the patch? Python gives me an error. Thank you!
@MetalComm Which IDE you are using,
For Colab IDE Use >> !pip install git+https://github.com/alvarobartt/investpy@403-patch
For other IDE, check with the pip
version or try using pip3
for python version 3+
pip3
thank you, but... is the URL correct? Beacause I get this error: Could not install requirement https://github.com/alvarobartt/investpy@403-patch because of HTTP error 404 Client Error: Not Found for url: https://github.com/alvarobartt/investpy@403-patch for URL https://github.com/alvarobartt/investpy@403-patch
Both
get_stock_recent_data
andget_stock_historical_data
are fixed in https://github.com/alvarobartt/investpy/tree/403-patch, I'll add the comments of the fix in an upcoming PR! In the meantime, you can install the latestinvestpy
version from403-patch
branch aspip install git+https://github.com/alvarobartt/investpy@403-patch
Did installed the patch and tried to run my programs, but still getting the same ConnectionError: ERR#0015: error 403, try again later.
BTW, I'm using the below:
investpy.get_index_historical_data()
investpy.search_quotes()
investpy.get_stock_recent_data()
Soooo it seems that it was working like 1 hour away or so and now suddenly stopped working again... So I'll keep on investigating it... It works from the browser and also from Postman, Thunder Client, and similar, but from Python it seems that it doesn't work now...
indices method still not work
df = investpy.indices.get_index_historical_data
Hi @Exganza so the fix is pending, since stocks
stopped working too in the 403-patch
branch for no reason (already using the new Investing.com API), so I got to fix it but then stopped working, I'm actively checking it! I'll let you all know whenever I have more updates, sorry for the inconvenience!
It seems that after a certain number of requests Cloudflare blocks you... So it's not stable...
Hi @Exganza so the fix is pending, since
stocks
stopped working too in the403-patch
branch for no reason (already using the new Investing.com API), so I got to fix it but then stopped working, I'm actively checking it! I'll let you all know whenever I have more updates, sorry for the inconvenience!
thank you @alvarobartt
I found incomplete solution using cloudscraper module. ( NOTE!, incomplete solution ) This module bypass cloudeflare.
- [OK] https://www.investing.com
url = 'https://www.investing.com'
###################################
import requests
req = requests.get(url)
print(req) # <Response [403]>
###################################
import cloudscraper
scraper = cloudscraper.create_scraper() # returns a CloudScraper instance
ret = scraper.get(url)
print(ret) # <Response [200]>
- [NOT OK] https://api.investing.com/api/financialdata/historical/43365?start-date=2022-08-19&end-date=2022-09-17&time-frame=Daily&add-missing-rows=false
url = 'https://api.investing.com/api/financialdata/historical/43365?start-date=2022-08-19&end-date=2022-09-17&time-frame=Daily&add-missing-rows=false'
###################################
import requests
req = requests.get(url)
print(req) # <Response [403]>
###################################
import cloudscraper
scraper = cloudscraper.create_scraper() # returns a CloudScraper instance
ret = scraper.get(url)
print(ret) # exception. "Cloudflare version 2 Captcha challenge"
'''
Traceback (most recent call last):
cloudscraper.exceptions.CloudflareChallengeError: Detected a Cloudflare version 2 Captcha challenge, This feature is not available in the opensource (free) version.
'''
additional reference https://splunktool.com/cloudscraperexceptionscloudflarechallengeerror-detected-a-cloudflare-version-2-challenge-error-when-i-used-cloudscraper-module-with-python
I'm a newbie so I'm probably missing something but scraping from the following url seems to work still fine (I don't know how long it will last) https://advcharts.investing.com/advinion2016/advanced-charts/9/9/16/GetRecentHistory?strSymbol=46891&iTop=1500&strPriceType=bid&strFieldsMode=allFields&lang_ID=9&strTimeFrame=1D
I'm a newbie so I'm probably missing something but scraping from the following url seems to work still fine (I don't know how long it will last) https://advcharts.investing.com/advinion2016/advanced-charts/9/9/16/GetRecentHistory?strSymbol=46891&iTop=1500&strPriceType=bid&strFieldsMode=allFields&lang_ID=9&strTimeFrame=1D
Nice @younggotti : D they forgot to burry this one, it can be a temporary solution
We need a ID and Description tables to match each symbol, cause the routine search-quotes doesn't work, yet.
its all available in the investpy resources folder -> Lib\site-packages\investpy\resources
ID col in stocks.csv
Hello,
I've got the same error with \investpy\bonds.py:596 in get_bond_historical_data raise ConnectionError(
ConnectionError: ERR#0015: error 403, try again later.
its all available in the investpy resources folder ->
Lib\site-packages\investpy\resources
ID col in stocks.csv
Thank you very much. It's completaly useful. We are available to replace the "search_quotes" routine, and access by each asset "investing.com" codes. It's a great news for me
I its not working, plz fix it or show us how to fix it