investiny: Request to Investing.com API failed with error code: 403
here is my code:
from investiny import historical_data
data = historical_data(investing_id=19256, from_date="01/01/2019", to_date="12/31/2019") #adese 19256 data-content-id üzerinden bulunuyor
here’s out:
runfile('C:/Users/emrec/Desktop/TUBITAK 22 DOSYASI/stockrates/untitled2.py', wdir='C:/Users/emrec/Desktop/TUBITAK 22 DOSYASI/stockrates')
Traceback (most recent call last):
File "C:\Users\emrec\AppData\Local\Programs\Python\Python39\lib\site-packages\spyder_kernels\py3compat.py", line 356, in compat_exec
exec(code, globals, locals)
File "c:\users\emrec\desktop\tubitak 22 dosyasi\stockrates\untitled2.py", line 3, in <module>
data = historical_data(investing_id=6408, from_date="01/01/2019", to_date="12/31/2019") #adese 19256 data-content-id üzerinden bulunuyor
File "C:\Users\emrec\AppData\Local\Programs\Python\Python39\lib\site-packages\investiny\historical.py", line 48, in historical_data
info = investing_info(investing_id=investing_id)
File "C:\Users\emrec\AppData\Local\Programs\Python\Python39\lib\site-packages\investiny\info.py", line 41, in investing_info
return request_to_investing( # type: ignore
File "C:\Users\emrec\AppData\Local\Programs\Python\Python39\lib\site-packages\investiny\utils.py", line 36, in request_to_investing
raise ConnectionError(
ConnectionError: Request to Investing.com API failed with error code: 403.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 1
- Comments: 24 (4 by maintainers)
Hi guys! So Investing.com has some severe limitations and strict Cloudflare protection so it’s probably that, I tried to contact them in the past in order to find a solution for this, but they didn’t reply, so it seems that they are not interested at all in having an open source project to pull data from their site and/or API. I’ll probably try to contact them again, but they are reluctant to do anything, so probably it will never work as smooth as before 😭
If I may shamelessly plug my project tessa – it’s an abstraction layer on top of data sources. It used to use investpy and coingecko. Now it uses yfinance and coingecko. It offers a streamlined interface and a number of features such as a
Symbol
class including collections to store and load a list of symbols. Might be useful for some people.https://info.signalsciences.com/rs/025-XKO-469/images/signal-sciences-case-study-investingcom.pdf doesn’t look like it’s gona work again any time soon. what a shame
Same issue here, tried from a remote server (different IP) in case of blacklist, and my own machine, both got 403.
@ivgomezarnedo
Amazing! Good job!
For Selenium, may be the problem is on the driver. User-Agent in http header is also an factor Cloudflare checks.
You can check on this link, https://stackoverflow.com/questions/68289474/selenium-headless-how-to-bypass-cloudflare-detection-using-selenium
@alvarobartt Can you contact me as I can share with you how to make it work 😃
So without
patch
I get 403 👎 but with some extra setup added I get proper responses as needed.