Exemple #1
0
        private static HtmlNode getDocumentNode(string URL)
        {
            HtmlNode docNode = null;
            using (var web = new CompressedWebClient())
            {
                bool tryAgain = true;
                string currentFile = null;
                while(tryAgain)
                {
                    try
                    {
                        currentFile = web.DownloadString(URL);
                        tryAgain = false;
                    }
                    catch (Exception ex)
                    {
                        System.Threading.Thread.Sleep(10000);
                    }
                }

                if (web.StatusCode() == System.Net.HttpStatusCode.OK)
                {
                    var doc = new HtmlDocument();
                    doc.LoadHtml(currentFile);
                    docNode = doc.DocumentNode;
                }
                else
                {
                    throw404(URL);
                }
            }
            return docNode;
        }
Exemple #2
0
        private static HtmlNode getDocumentNode(string URL)
        {
            HtmlNode docNode = null;

            using (var web = new CompressedWebClient())
            {
                bool   tryAgain    = true;
                string currentFile = null;
                while (tryAgain)
                {
                    try
                    {
                        currentFile = web.DownloadString(URL);
                        tryAgain    = false;
                    }
                    catch (Exception ex)
                    {
                        System.Threading.Thread.Sleep(10000);
                    }
                }

                if (web.StatusCode() == System.Net.HttpStatusCode.OK)
                {
                    var doc = new HtmlDocument();
                    doc.LoadHtml(currentFile);
                    docNode = doc.DocumentNode;
                }
                else
                {
                    throw404(URL);
                }
            }
            return(docNode);
        }