Scraping a webpage with C# and HTMLAgility

后端 未结 2 481
半阙折子戏
半阙折子戏 2020-12-06 07:56

I have read that HTMLAgility 1.4 is a great solution to scraping a webpage. Being a new programmer I am hoping I could get some input on this project. I am doing this as a c

2条回答
  •  [愿得一人]
    2020-12-06 08:22

    The beginning part is off:

    HtmlDocument doc = new HtmlDocument();
    doc.LoadHtml("http://localhost");   
    

    LoadHtml(html) loads an html string into the document, I think you want something like this instead:

    HtmlWeb htmlWeb = new HtmlWeb();
    HtmlDocument doc  = htmlWeb.Load("http://stackoverflow.com");
    

提交回复
热议问题