コード例 #1
0
ファイル: City.cs プロジェクト: T1G0FF/DimmiScraper
        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;
        }
コード例 #2
0
ファイル: City.cs プロジェクト: T1G0FF/DimmiScraper
        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);
        }