コード例 #1
0
        internal static async Task GetPhones(this Auto auto)
        {
            try
            {
                var sb = new StringBuilder("http://ab.onliner.by/car/");
                sb.Append(auto.Id);
                WebRequestBuilder builder = new WebRequestBuilder("ab.onliner.by", new Uri(sb.ToString()), "http://ab.onliner.by");
                var wReq = builder.Build();

                using (var resp = (HttpWebResponse)await wReq.GetResponseAsync())
                {

                    using (var sr = new StreamReader(resp.GetResponseStream(), Encoding.UTF8))
                    {
                        var html = sr.ReadToEnd();
                        var match = AutoBaraholkaParcer.Regex.Match(html);
                        while (match.Success)
                        {
                            auto.PhoneNumbers.Add(match.Value);
                            match = match.NextMatch();
                        }
                    }
                }
            }
            catch
            {
                // ignored
            }
        }
コード例 #2
0
        protected override void PostRequest()
        {
            try
            {
                var builder = new WebRequestBuilder("ab.onliner.by", Uri, "http://ab.onliner.by")
                { Method = "post", Accept = "application/json, text/javascript, */*; q=0.01"};
                var wReq = builder.Build();

                using (var resp = (HttpWebResponse)wReq.GetResponse())
                {

                    using (var sr = new StreamReader(resp.GetResponseStream(), Encoding.UTF8))
                    {
                        Response = sr.ReadToEnd();
                    }
                }
            }
            catch
            {
                // ignored
            }
        }