-
-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request to Investing.com API failed with error code: 403 #73
Comments
Same issue here, tried from a remote server (different IP) in case of blacklist, and my own machine, both got 403. |
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 😭 |
Hi @alvarobartt , great job my friend well done! Just sent to you 5 bat Why not use tradingview instead of investing.com |
https://info.signalsciences.com/rs/025-XKO-469/images/signal-sciences-case-study-investingcom.pdf |
Does anyone have any other option to obtain historical data of investment funds, etc? |
we just have yfinance.
it is really big shame. supporting open source projects should be no problem on modern internet but clearly we can see still we have some blind minds problem. |
Yes, guys... I know it's a shame, also I tried my best to contact them but it seems they are not keen to help! @JosePereiraUA regarding your question, the most popular options were either Both had some pros/cons, but Yahoo! Finance offers an actual API, which makes that project more stable, This said, I'm still waiting for Investing.com's response, which I assume will never come since it's been already 2 months waiting for it, and people from Investing.com were just redirecting me to contact more and more people and at the end no one answered... |
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 |
@alvarobartt Can you contact me as I can share with you how to make it work :) So without
|
Sure @RafPe, I'm happy you made it work! Feel free to email me at alvarobartt@gmail.com and we can continue the conversation there, and I'm also happy to make you a collaborator if the fix is worth adding 😄 |
Thank you for the big work @alvarobartt |
aswsome open project, i hope we can fix 403 error |
same problem |
Just realized that when you send request to server, need to include __cf_bm in the http request header "cookie" field. The __cf_bm is something like the following:
Of cause you can find this cookie string via your web browser, and manually set in the script and then run. But the problem is how to dynamically get this cookie instead of do it in a manual way? Anyone has any clue? |
This cookie is Cloudflare's bot manager and just copy paste will not cut the chase as additional checks exist on their serverside |
Manually set the HTTP header will work. "Origin", "Referer", "Host", "Domain-Id" and "Cookie". The reset fields are static value, except "Cookie". Must set valid value for "__cf_bm" and "__cflb" in the cookie field.
Looks like there is no way to fully automate this, as the server checks TLS fingerprint. There are some work to be done in order to send the correct the TLS fingerprint. Not worth the effort. |
I think you should not give up @zh1cheng ... there has been work done on that front and u can just simply use it here https://github.com/lwthiker/curl-impersonate |
@RafPe Thanks for the link. Need sometime to study. By the way, there might be another solution, can anyone try it? Use the Selenium with Python, looks like able to do the similar things: |
@zh1cheng you need to take under the consideration that the the bot manager solution from Cloudflare will detect ( in most of the cases ) the automated browser and will eventually block you. So your best choice would be to bake the app into a docker container where you can easily use the framework I referenced as linked libraries or create a method interface in the code that would execute the calls instead :) |
@RafPe thanks for your comments. I have been able to make the library work again by modifying how the requests are being done (instead of using httpx, it uses the subprocess package to directly call to curl-impersonate ) and it works fine! I'm curious about what you said:
Do you know why Cloudflare could detect a Selenium implementation but not an implementation that use curl-impersonate? Furthermore, I don't know what would be the best option to push my working changes (as these changes will add a dependency with curl-impersonate, to create a merge request, to create a fork of the repo...? |
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 |
A simple Python module to bypass Cloudflare's anti-bot page |
Thanks for sharing, tried that in the past but had no success with Cloudflare v2 |
I come up an idea, |
So I was checking the 403 error that I was having and after messing with random user-agent, different headers... I just swapped the library httpx -> requests, and for some reason it is working. The change was here: investiny/utils.py . For sure this has some explanation, and I'm probably missing some points here. Anyway, sorry if I've bothered you! |
Same issue here, tried the edits suggested by @sleo0182 but I still get the same error. |
here is my code:
here's out:
The text was updated successfully, but these errors were encountered: