开发者

C HTMLagilitypack exception help

开发者 https://www.devze.com 2023-01-10 06:56 出处:网络
foreach (string mul in masterurlList) { HtmlWeb hwObject = new HtmlWeb(); HtmlAgilityPack.HtmlDocument htmldocObject = hwObject.Load(mul);
foreach (string mul in masterurlList)
        {
            HtmlWeb hwObject = new HtmlWeb();
            HtmlAgilityPack.HtmlDocument htmldocObject = hwObject.Load(mul);
            List<string> hrefTags = new List<string>();
            try
            {
                hrefTags = ExtractAllAHrefTags(htmldocObject);
            }
            catch (Exception)
            { }

I already have an catch(exception) in my code but what happens in on HtmlAgilityPack.HtmlDocume开发者_JAVA百科nt htmldocObject = hwObject.Load(mul) i get WebException was unhandled. The remote name could not be resolved: 'www.eonline.com'

I can't get rid of the try and catch that i have, and if i expand my try area i lose all my strings. any help would be awesome! And i know my DNS is good


Expand the try area like this to keep your strings...

   foreach (string mul in masterurlList)
            {
                List<string> hrefTags = new List<string>();
                try
                {
                HtmlWeb hwObject = new HtmlWeb();
                HtmlAgilityPack.HtmlDocument htmldocObject = hwObject.Load(mul);
                    hrefTags = ExtractAllAHrefTags(htmldocObject);
                }
                catch (Exception)
                { }
            }
0

精彩评论

暂无评论...
验证码 换一张
取 消