javascripturlgetelementbyidcurrency-exchange-rates

Reading real-time value from HTML element in URL page using jQuery


I've got this website: https://coinyep.com/he/ex/ETH-ILS

Inside this URL web page, there is an input element, and its HTML id is: "coinyep-input2".

I need to read its value (= approximately 637.49 ILS) using jQuery in Visual Studio.

So far, I tried everything, no success. Any help will be appreciated.

For example, in jQuery there is a command :

 document.getElementById("coinyep-input2"); 

==> I need to do the same thing but to do it from the URL page in order to get values in real-time (exchange rates).


Solution

  • For now, I found solution in C# (server), using it by Razor on the client [Based on RSS URL]:

       public float getExchangeRate_ETH_To_ILS()
        {
            float exchangeRate;
            string[] words;
            int indexOfExchangeRate;
    
            using (var client = new WebClient())
            {
                try
                {
                    var htmlPage = client.DownloadString("https://coinyep.com/he/rss/ETH-ILS.xml");
                    words = htmlPage.Split(' ');
                    indexOfExchangeRate = words.IndexOf("ILS");
                    exchangeRate = (float)Convert.ToDouble(words[indexOfExchangeRate - 1]);
    
                }
                 catch(Exception e)
                 {                        
                    exchangeRate = -1;
                 }
            }
            return exchangeRate;
        }
    

    in the client, I use this fucntion via model (Razor):

      var cal1 = @Model.getExchangeRate_ETH_To_ILS(); 
    

    But there is a risk: if the template of the RSS will be changed, we are in trouble.