Пример #1
0
        private void ProcessHtmlPage(HttpClient httpClient, HttpResponseMessage response, Uri url, int depthLevel)
        {
            Stream       stream       = response.Content.ReadAsStreamAsync().Result;
            MemoryStream memoryStream = new MemoryStream();

            stream.CopyTo(memoryStream);
            stream.Seek(0, SeekOrigin.Begin);

            CQ cq = CQ.Create(stream, Encoding.UTF8);

            _saver.SaveHtmlPage(url, this.GetHtmlPageName(cq), memoryStream);

            foreach (IDomObject el in cq.Find("a"))
            {
                this.ProcessUrl(httpClient, new Uri(httpClient.BaseAddress, el.GetAttribute("href")), depthLevel + 1);
            }

            memoryStream.Close();
            stream.Close();
        }