开发者

WebBrowser doesn't update the DocumentText?

Whenever I assign Id's to some elements via HtmlElement.Id, and then read the WebBrowser.DocumentText property, the Id of the element doesn't have the Id I assigned to it. Seems to me that the DocumentText is the IExplorer 'interpretation' of the web page, discarding everything that doesn't consider relevant to the visual aspects of the page. I tryed getting the Id via HtmlElement.Id and the Id was the one I assigned, but what I need is to find a way to map from an HtmlDocument (.net) to a HtmlAgilityPack.HtmlDocument, so I want to assign an unique Id to every single element, then read the DocumentText with HtmlAgilityPack and then GetElementById on both sides every time I want to access a particular element. But since I'm using DocumentText to give the Html code to HtmlAgilityPack, HtmlAgilityPack is not getting the unique Id's. The reason why I need to map from one to another is because I'm creating a web Scraper that will update the visual aspects of a web page according to selections the user do (highlight stuff, etc.), but I need to keep a copy of the original html to do the actual scraping开发者_如何学JAVA, otherwise the scraping will be messed up by the changes I make to the html. Any suggestions?


Maybe you need to wait for some time to pass...from MSDN on WebBrowser.DocumentText:

"If you set the value of this property and then immediately retrieve it again, the value retrieved may be different than the value set if the WebBrowser control has not had time to load the new content."

Maybe this also applies to if you set an element's ID and then immediately read the DocumentText property?


please refer to this answer: c# filenotfoundexception on webbrowser?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜