Esempio n. 1
0
        private PriceMatches RegSearch(string html)
        {
            var matches1 = SerachType1(html);
            var matches2 = SerachType2(html);

            var matches = new PriceMatches {
                StrValues = matches1.Union(matches2).ToList()
            };

            ParseMatches(ref matches, matches1, matches2);
            return(matches);
        }
Esempio n. 2
0
        private double ParsePrice(string html, string[] variants)
        {
            PriceMatches mathces = RegSearch(html);

            for (int i = 0; i < mathces.StrValues.Count(); i++)
            {
                foreach (var variant in variants)
                {
                    if (mathces.StrValues[i].IndexOf(variant) != -1)
                    {
                        return(mathces.NumValues[i]);
                    }
                }
            }

            throw new Exception("Price isn't found in HTML code");
        }
Esempio n. 3
0
        private void ParseMatches(ref PriceMatches mathces, IEnumerable <string> matches1, IEnumerable <string> matches2)
        {
            var temp_matches = matches1.Union(matches2.Select(x => x.Replace(",", "")))
                               .Select(x => x.Replace(" ", ""))
                               .Select(x => Regex.Replace(x, dots, ".")).ToArray();


            mathces.NumValues = new List <double>();
            for (int i = 0; i < temp_matches.Count(); i++)
            {
                try
                {
                    mathces.NumValues.Add(double.Parse(temp_matches[i], CultureInfo.InvariantCulture));
                }
                catch (Exception)
                {
                    mathces.NumValues.Add(-1);
                }
            }
        }