In VB how can I use a website url to create an HtmlDocument object that contains all the html from that webpage?
I was trying to 开发者_JS百科use HtmlDocument and a given url to pull in the html contents of a website to use. However there is no constructor for HtmlDocument and it's Url property is readonly.
Is there any way to create an object that contains the entire DOM for a given url?
Thanks,
Matthttp://msdn.microsoft.com/en-us/library/system.windows.forms.htmldocument.aspx
I don't mean to point out the obvious but the first line in the documentation says - Provides top-level programmatic access to an HTML document hosted by the WebBrowser control.
This would explain why the URL property is read only. Not sure on why you need the HTML for visual or non visual purposes, but as a start you could set the URL property of the WebBrowser control, then grab the htmlDocument of the WebBrowser control after load.
This might be a cheap hack, if you're really after the clean html response from the server, and I am sure there are other non visual controls out there better to use than the WebBrowser control.
精彩评论