I am using HtmlAgilityPack to grab a table from a web page.
HtmlWeb web = new HtmlWeb();
HtmlDocument doc = web.Load("http://test.com");
I am aware that HtmlWeb has a UserAgent property, however I have no idea how I am supposed to attach a user agent to the header of the httprequest.
HtmlWeb web = new HtmlWeb().UserAgent("asdf");
returns the error
Error 1 Non-invocable member 'HtmlAgilityPack.HtmlWeb.UserAgent' cannot be used like a method.
http://htmlagilitypack.codeplex.com/discussions HtmlAgilityPack support discussions appear as simply questions, but nobody on the other end to respond.
http://htmlagilitypack.codeplex.com/documentation There is NO documentation here yet.
http://htmlagilitypack.codeplex.com/downloads/get/437942 Tried downloading the documentation, to find that the chm file seems broken... I'm getting a Navigation to the webpage was cancelled error when I try to open anything within the chm documentation.
Just set the UserAgent
property of the HtmlWeb
object after instantiating it.
HtmlWeb web = new HtmlWeb();
web.UserAgent = "your useragent string here";
HtmlWeb.UserAgent is a property, not a method. Its Intellisense summary is:
Gets or Sets the User Agent HTTP 1.1 header sent on any webrequest
Try something like:
HtmlWeb web = new HtmlWeb();
web.UserAgent = "asdf"; // Replace this with your actual user agent :)