Exemplo n.º 1
0
        private string GetPrice()
        {
            startPrice = Substring.GetSubstringNoIncluded(text, @"Стартовая цена:", "\nМинимальный шаг:");

            if (this.comments.count == 0)
            {
                return(string.Concat(startPrice, @" / 0"));
            }

            string GetCommentURL = string.Concat
                                   (
                "https://api.vk.com/method/wall.getComments?access_token=", access_token[0],
                "&owner_id=", owner_id,
                "&v=5.52&count=1&sort=desc&post_id=", id
                                   );

            List <Comment> comments = new List <Comment>();

            using (WebClient wc = new WebClient())
            {
                string JsonComment = wc.DownloadString(GetCommentURL);
                JsonComment = @"{" + Substring.GetSubstringStartIncluded(JsonComment, @"""items", "}}") + @"}";
                Thread.Sleep(300);
                comments = Converter <Comment> .JsonToList(JsonComment, "items");
            }
            if (comments == null)
            {
                return(string.Empty);
            }
            price = comments[0]?.ToString();
            price = Encoding.UTF8.GetString(Encoding.Default.GetBytes(price)); // Black Magic
            price = Substring.GetSubstringNoIncluded(price, "(", " рублей)");
            return(string.Concat(startPrice, " / ", price));
        }