Пример #1
0
        public static async Task <String> FetchAsync(String uri, Boolean assumeUnicode = false)
        {
            var webClient = new ScrapeClient(uri, userAgent: USER_AGENT, assumeUnicode: assumeUnicode);
            var html      = await webClient.GetPageAsync();

            return(html);
        }
Пример #2
0
        public static async Task <HtmlNode> FetchParseAsync(String uri, String proxy        = null, Boolean assumeUnicode = false, Int32?timeoutSecs = null,
                                                            Func <string, string> transform = null)
        {
            var webClient = new ScrapeClient(uri, userAgent: USER_AGENT, assumeUnicode: assumeUnicode, proxy: proxy, timeoutSecs: timeoutSecs);
            var html      = await webClient.GetPageAsync();

            if (transform != null)
            {
                html = transform(html);
            }

            var htmlDocument = new HtmlDocument();

            htmlDocument.LoadHtml(html);

            var htmlNode = htmlDocument.DocumentNode;

            return(htmlNode);
        }