investpy: 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.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 7
- Comments: 106 (27 by maintainers)
Commits related to this issue
- Merge branch 'replace-investpy' - Add the symbol functionality/interface, namely new classes `Symbol` and `SymbolCollection`. - Remove investpy because it is no longer working, see https://github... — committed to ymyke/tessa by ymyke 2 years ago
- š Update `README.md` Add installation notes as requested at https://github.com/alvarobartt/investpy/issues/600#issuecomment-1265167355 — committed to alvarobartt/investiny by alvarobartt 2 years ago
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!
So Iāve already contacted Investing.com and started a conversation there, Iāll let you all know the outcome of it. Thanks for your patience! š¤
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
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ā¦
Hi guys, Iām having the same problem, does anyone have any tips to get around this situation?
dados_usd_brl = investpy.currency_crosses.get_currency_cross_historical_data(currency_cross=āUSD/BRLā, from_date=ā04/11/2019ā, to_date= ā01/01/2024ā)
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!Hello everyone!
I was using a custom script for investing.com, which led me to investpy when things broke.
I ended up building a solution, but feel guilty not sharing it with everyone stuck on this issue. So, here is the API to bypass Cloudflare: http://api.scraperlink.com/investpy/
Using it in your scripts is just a matter of prefixing your current fetch requests with this: http://api.scraperlink.com/investpy/?email=your@email.com&url=
Example:
I have also added another option that supports historical data for stocks, cryptos and currencies for now:
If thereās interest from the community, I am happy to add more features and data points.
Just let me know whatās important to you.
Hi everyone! Good news š
Iāve just released
investiny
which is a tinyinvestpy
with a single function to download the historical data from Investing.com, check it out at https://github.com/alvarobartt/investiny (support is welcomed so if itās useful to you in the meantime whileinvestpy
is fixed please star it and share it so that anyone can use it while we fixinvestpy
)Thanks to everyone contributing and helping out! š¤
I guess that one possible solution is using origin server ip adress of āapi.investing.comā instead of cloudflare ip address.
reference https://www.youtube.com/watch?v=Cfbi5-Knpxk https://blog.detectify.com/2019/07/31/bypassing-cloudflare-waf-with-the-origin-server-ip-address/
But, I canāt found origin server ip address of āapi.investing.comā. ( āCloudFailā canāt find it. )
Can anyone do it?
You can use the workaround API that I built for this community: http://api.scraperlink.com/investpy/
For example, hereās the sample API for stocks:
Thanks, @samjmck this is really useful, thereās a limitation on the daily period itās retrieved 365 days maximum, but still very useful
Commodity historical data not working
investpy.get_commodity_historical_data
ConnectionError: ERR#0015: error 403, try again later.
hi, still having issues.
import investiny from investiny import historical_data data = historical_data(investing_id=6408, from_date=ā09/01/2022ā, to_date=ā10/01/2022ā)
i get āConnectionError: Request to Investing.com API failed with error code: 403.ā**
Thanks @KostyaCholak can you please open a separate issue at https://github.com/alvarobartt/investiny? Iāll try to test that approach later today, thanks!
Hi @ymyke so we are mentioning the source the data comes from and itās a publicly available API. What may violate those is to actually bypass their protection protocols, but not sure, this is why Iām telling people developing their own solutions to contact Investing.com just like I did some time ago, to get their approval.
FYI Iāve created here an issue at https://github.com/alvarobartt/investpy/issues/611, and a Discussing at https://github.com/alvarobartt/investpy/discussions/612, both are pinned and have some details on how to use
investiny
which is a tiny version ofinvestpy
that Iāve just created so as to develop there some temporary solutions to keep on pulling data from Investing.com, without having to bypass their protection or violate their terms of use.How do we get the investing_id? running search quotes on investor gives the same 403 error
It seems that after a certain number of requests Cloudflare blocks youā¦ So itās not stableā¦
I donāt think that error is from me. Whatās the query youāre using?
You can use
investiny
in the meantime, even though at some point youāll face the same issue with Investing.com temporarily blocking you if you send too many requestsā¦ Iāve already contacted Investing.com in order to look for a solution to thisā¦ Iāll keep you all posted regarding this matter!hello everyone, my name is andres, I am a python programming student and investPY made me very happy, I would like to know if maybe investPY could find a solution by the end of the year? I donāt know how serious the error is but from what Iāve been investigating it seems to be an update issue of investing.com itself. I thank all developers for their time and stay tuned.
Hi, @AyseTheArk do you mind opening that as a separate issue at https://github.com/alvarobartt/investiny/issues? Otherwise is just a mess for me to go through all the issues here, thanks!
Hi @fredericojordan, so this works if doing it manually, but Iām planning to actually develop a way to automatically retrieve those in order to avoid either manual search or relying on static CSV files!
Please star
investiny
and create all the related issues there, not here, as itās easier for me to track, thanks! š¤For anyone looking to temporarily switch to yahoo for prices, market-prices offers an interface with enhanced querying and additional functionality.
I was hoping to add
investpy
as a data source formarket-prices
although was waiting for intraday data to be added (I know there had been intermittent chatter about this). Ifinvestpy
can get back up and running (š¤š¤) then Iāll look to add it as a option for the source data.Good luck @alvarobartt!
EDIT: for anyone looking at market-prices, the pandas dependency is temporarily <= 1.4.4 (working on a fix for the recent 1.5 release - https://github.com/maread99/market_prices/issues/89).
So to everyone looking for an alternative as @ymyke is mentioning you can use finance from @ranaroussi, or even his own custom package
tessa
which is currently usingyfinance
in the background.It might be worth using a MITM proxy on an Android or iOS device to check the requests the mobile app is making to the server. Those might be different to the web app and might not have the same protections.
Hi guys, so thereās not much progress from my side, as it seems that the Cloudflare protection cannot be ignored, so the patch just works for a limited number of requestsā¦ But ends up failing every time!
In my case, itās useful, for instance:
ident = <path>+āstocks.xlsxā read_tag = pd.read_excel(ident) ā¦ tag2 = read_tag[read_tag[ācountryā] == āunited statesā] tag3 = tag2.loc[tag2[āsymbolā] == āTSLAā, ātagā] tag = tag3.values[0]
ex: https://www.investing.com/equities/tesla-motors-ratios
url = āhttps://www.investing.com/equities/ā+tag+ā-ratiosā driver.get(url)
get Price to Cash Flow
find_rating = driver.find_element(By.XPATH, ā(//tr[@id=āchildTrā]/td/div/table/tbody/tr[3]/td[2])ā) p_cf = find_rating.text
its all available in the investpy resources folder ->
Lib\site-packages\investpy\resources
ID col in stocks.csvIā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
Hi again everyone, feel free to track the progress of the patch at https://github.com/alvarobartt/investpy/pull/602 š¤ 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
Iāve the same issue, from my investigation https://www.investing.com/instruments/HistoricalDataAjax seems to be discontinued!