我不知道如何用GeckoFX将网站的源代码放到一个字符串中。
当我使用
GeckoWebBrowser1.ViewSource("www.google.de")一个新的窗口将打开,里面有源代码,很高兴看到,但没有机会将其加载到字符串中。
当我使用
GeckoWebBrowser1.Navigate("view-source:www.google.de")源代码显示在GeckoFX浏览器中,但我也不知道如何将其转换为字符串。
我确信解决方案很简单,但我看不出来。因此,如果有人能帮助我摆脱这场斗争,那就太好了。
发布于 2016-07-18 07:56:48
每个人都有很多方法来检索网站的html。如前所述,您可以使用WebClient类来检索它,或者在本例中使用GeckoFX。为了获得内部html,您需要先研究DocumentElement,然后再研究GeckoHtmlElement……
Dim element As GeckoHtmlElement = Nothing
Dim geckoDomElement = GeckoWebBrowser1.Document.DocumentElement
If TypeOf geckoDomElement Is GeckoHtmlElement Then
element = DirectCast(geckoDomElement, GeckoHtmlElement)
If element IsNot Nothing AndAlso element.InnerHtml IsNot Nothing Then
Dim innerHtml = element.InnerHtml 'this is the source of the webpage. Here do what you want with the html...
End If
End Ifhttps://stackoverflow.com/questions/38425412
复制相似问题