Skip to content
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

I got a way to access investing without cloudflare u can try it with requests library #610

Closed
ramakrishnamekala129 opened this issue Sep 30, 2022 · 16 comments

Comments

@ramakrishnamekala129
Copy link

import requests
from requests.structures import CaseInsensitiveDict

url = "https://tvc4.investing.com/b12dcd570c91a748a3b7dd4a7ee79167/1664515691/56/56/23/history?symbol=101810&resolution=D&from=1633411692&to=1664515752"

headers = CaseInsensitiveDict()
headers["authority"] = "tvc4.investing.com"
headers["accept"] = "/"
headers["accept-language"] = "en-US,en;q=0.9"
headers["content-type"] = "text/plain"
headers["origin"] = "https://tvc-invdn-com.investing.com"
headers["referer"] = "https://tvc-invdn-com.investing.com/"
headers["sec-fetch-dest"] = "empty"
headers["sec-fetch-mode"] = "cors"
headers["sec-fetch-site"] = "same-site"
headers["user-agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.102 Safari/537.36"

resp = requests.get(url, headers=headers)

print(resp.status_code)
resp.json()

@ramakrishnamekala129
Copy link
Author

in this b12dcd570c91a748a3b7dd4a7ee79167 is just like apitoken once u get it then u access all historical data

@ramakrishnamekala129
Copy link
Author

ramakrishnamekala129 commented Sep 30, 2022

why requests library doesnt work because of http2or3 version in investing protocol thats why we can use CaseInsensitiveDict

@ramakrishnamekala129
Copy link
Author

api key generated from md5 format

@ramakrishnamekala129 ramakrishnamekala129 changed the title I got a way to access investing without cloudflare u can try it I got a way to access investing without cloudflare u can try it with requests library Sep 30, 2022
@alvarobartt
Copy link
Owner

Hi, @ramakrishnamekala129 can you elaborate a little bit more on what those parameters in the URL mean? Thanks 🤗

  • https://tvc4.investing.com -> API Host
  • b12dcd570c91a748a3b7dd4a7ee79167 -> API Token? Where did you get this from?
  • 1664515691 -> Unknown
  • 56 -> Unknown
  • 56 -> Unknown
  • 23 -> Unknown
  • history -> HTTP GET Endpoint
  • symbol=101810 -> Investing.com symbol parameter
  • resolution=D -> Investing.com interval parameter (I assume this can be D, W, or M)
  • from=1633411692 -> Investing.com from_date as timestamp parameter
  • to=1664515752 -> Investing.com to_date as timestamp parameter

@ramakrishnamekala129
Copy link
Author

Hi, @ramakrishnamekala129 can you elaborate a little bit more on what those parameters in the URL mean? Thanks 🤗

  • https://tvc4.investing.com -> API Host
  • b12dcd570c91a748a3b7dd4a7ee79167 -> API Token? Where did you get this from?
  • 1664515691 -> current time
  • 56 -> Fized parameter for all
  • 56 -> Fixed parameter for all
  • 23 -> Fixed parameter for all
  • history -> HTTP GET Endpoint
  • symbol=101810 -> Investing.com symbol parameter
  • resolution=D -> Investing.com interval parameter (I assume this can be D, W, or M)
  • from=1633411692 -> Investing.com from_date as timestamp parameter
  • to=1664515752 -> Investing.com to_date as timestamp parameter

b12dcd570c91a748a3b7dd4a7ee79167 is md5 encode it will work for all

@ramakrishnamekala129
Copy link
Author

U can generate any random md5 code for api

ymyke added a commit to ymyke/tessa that referenced this issue Sep 30, 2022
- Add the symbol functionality/interface, namely new classes `Symbol`
  and `SymbolCollection`.
- Remove investpy because it is no longer working, see
  alvarobartt/investpy#600 and
  alvarobartt/investpy#610
- Add yfinance / Yahoo Finance support instead (simplifying a number of
  things in the interfaces such as type_, country and _querytype).
- Revamp search interface, now supports filtering and bucketizing,
  returns Symbol objects. See new `SearchResult` class for more information.
- Add much more comprehensive documentation.
- Revamp folder structure.
- Encapsulate everything related to sources in new `Source` class. All
  symbols have a `source` attribute now. (`source` attribute is roughly
  a replacement for the old `type_` attribute.)
- Signatures of most/all `price_*` functions changed.
- Add a number of types such as `SourceType`, `PriceHistory`, or
  `PricePoint` to make the code clearer and help with autocomplete
  suggestions in the IDE.
@alvarobartt
Copy link
Owner

OK thanks @ramakrishnamekala129 I'll test your proposal and if it works I'll push some changes to the patch branch 😄

@alvarobartt
Copy link
Owner

I've just tested it and it doesn't work consistently, it works for some requests, but then it stops working... Same as with api.investing.com, it works the first times then you get instantly blocked 😢

@ramakrishnamekala129
Copy link
Author

I've just tested it and it doesn't work consistently, it works for some requests, but then it stops working... Same as with api.investing.com, it works the first times then you get instantly blocked 😢

can u share blocking msg

@ramakrishnamekala129
Copy link
Author

it is not blocking me
while True:
url = "https://tvc4.investing.com/0e818888003657176127862245791911/1664515691/56/56/23/history?symbol=101810&resolution=D&from=1633411692&to=1664515752"

headers = CaseInsensitiveDict()
headers["authority"] = "tvc4.investing.com"
headers["accept"] = "*/*"
headers["accept-language"] = "en-US,en;q=0.9"
headers["content-type"] = "text/plain"
headers["origin"] = "https://tvc-invdn-com.investing.com"
headers["referer"] = "https://tvc-invdn-com.investing.com/"
headers["sec-fetch-dest"] = "empty"
headers["sec-fetch-mode"] = "cors"
headers["sec-fetch-site"] = "same-site"
headers["user-agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.102 Safari/537.36"


resp = requests.get(url, headers=headers)

print(resp.status_code)
time.sleep(1)
if resp.status_code==200:
    print(resp.json())

@alvarobartt
Copy link
Owner

Ok, you're right! The error just appears when I try to replace the current time value you mentioned with the current timestamp value, otherwise, it works! I'll probably release something with this patch in the meantime, thanks 🤗

@alvarobartt alvarobartt reopened this Sep 30, 2022
alvarobartt added a commit to alvarobartt/investiny that referenced this issue Sep 30, 2022
As suggested by @ramakrishnamekala129 at alvarobartt/investpy#610 there's another way to access Investing.com historical data, so I've implemented a simple function to pull that data
@alvarobartt
Copy link
Owner

I've just released investiny with a function to retrieve historical_data with your proposal @ramakrishnamekala129, check it at https://github.com/alvarobartt/investiny 🤗

@elricStormBringer
Copy link

it is not blocking me while True: url = "https://tvc4.investing.com/0e818888003657176127862245791911/1664515691/56/56/23/history?symbol=101810&resolution=D&from=1633411692&to=1664515752"

headers = CaseInsensitiveDict()
headers["authority"] = "tvc4.investing.com"
headers["accept"] = "*/*"
headers["accept-language"] = "en-US,en;q=0.9"
headers["content-type"] = "text/plain"
headers["origin"] = "https://tvc-invdn-com.investing.com"
headers["referer"] = "https://tvc-invdn-com.investing.com/"
headers["sec-fetch-dest"] = "empty"
headers["sec-fetch-mode"] = "cors"
headers["sec-fetch-site"] = "same-site"
headers["user-agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.102 Safari/537.36"


resp = requests.get(url, headers=headers)

print(resp.status_code)
time.sleep(1)
if resp.status_code==200:
    print(resp.json())

@ramakrishnamekala129 , I used this snippet, and unfortunately, it just loos with a 403 error code. This is as of 17/11/2022, United Kingdom location.

@ramakrishnamekala129
Copy link
Author

Because we used this api that why investing.com close this backend api

@KapteinBabbalas
Copy link

KapteinBabbalas commented Nov 18, 2022

Because we used this api that why investing.com close this backend api

I dont think that is the case.
If you open the url in any browser it works perfectly.
If you just do a get in postman for that link you see that it return html with a form and a script with a function in there that does some magic in the window. I'm not that clued up with front end but maybe have a look to see if you can take that raw response and do something with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants