Пример #1
0
        private double ParseLastDealRate(string webData)
        {
            var pos        = webData.IndexOf("Курс последней сделки", StringComparison.Ordinal);
            var posFrom    = webData.IndexOf("<td>", pos + 2, StringComparison.Ordinal);
            var posTo      = webData.IndexOf("</td>", posFrom + 2, StringComparison.Ordinal);
            var rateString = webData.Substring(posFrom + 5, posTo - posFrom - 1);
            var rate       = SpecialOperations.ParseDoubleFromWebTrash(rateString);

            return(rate);
        }
Пример #2
0
        private double ParseDealsCount(string webData)
        {
            var pos        = webData.IndexOf("Количество сделок", StringComparison.Ordinal);
            var posFrom    = webData.IndexOf("<td>", pos + 2, StringComparison.Ordinal);
            var posTo      = webData.IndexOf("</td>", posFrom + 2, StringComparison.Ordinal);
            var rateString = webData.Substring(posFrom + 5, posTo - posFrom - 1);
            var rate       = SpecialOperations.ParseDoubleFromWebTrash(rateString);

            return(rate);
        }
 private static double ParseValue(string table, string param)
 {
     try
     {
         var pos         = table.IndexOf(param, StringComparison.Ordinal);
         var posFrom     = table.IndexOf("<td>", pos, StringComparison.Ordinal) + 4;
         var posTo       = table.IndexOf("</td>", posFrom, StringComparison.Ordinal);
         var valueString = table.Substring(posFrom, posTo - posFrom).Trim();
         return(SpecialOperations.ParseDoubleFromWebTrash(valueString));
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(-1);
     }
 }
Пример #4
0
        private void GetForCurrency(string table, string currency, out double rate, out string volume)
        {
            var key = string.Format("<a href=\"/exchange/currencymarket/{0}\">{1}</a>", currency.ToLower(), currency);
            var pos = table.IndexOf(key, StringComparison.Ordinal);

            pos = table.IndexOf("<p class=\"text-center h1 mt-0\">", pos + 5, StringComparison.Ordinal);
            var posFrom = pos + 29;
            var posTo   = table.IndexOf("<span", posFrom, StringComparison.Ordinal);

            if (posTo - posFrom - 2 < 0)
            {
                rate   = -1;
                volume = "";
                return;
            }
            var rateString = table.Substring(posFrom, posTo - posFrom - 2);

            rate = SpecialOperations.ParseDoubleFromWebTrash(rateString);

            pos     = table.IndexOf(">Объём, млн. USD</span>", posTo, StringComparison.Ordinal);
            posFrom = table.IndexOf(">", pos + 27, StringComparison.Ordinal);
            posTo   = table.IndexOf("</span", posFrom, StringComparison.Ordinal);
            volume  = table.Substring(posFrom + 1, posTo - posFrom - 1);
        }