如标题中所述,我试图让我的vb.net应用程序忽略源代码,只显示文本在网站上。我希望它忽略代码pre和/ code / pre 这是我的代码:
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim Str As System.IO.Stream
Dim srRead As System.IO.StreamReader
Try
Dim req As System.Net.WebRequest = System.Net.WebRequest.Create("http://junkcode.gehaxelt.in/")
Dim resp As System.Net.WebResponse = req.GetResponse
Str = resp.GetResponseStream
srRead = New System.IO.StreamReader(Str)
RichTextBox1.Text = srRead.ReadToEnd
Catch ex As Exception
RichTextBox1.Text = "Content Cannot Be Downloaded"
Finally
srRead.Close()
Str.Close()
End Try
End Sub
Private Sub VScrollBar1_Scroll(sender As Object, e As ScrollEventArgs)
End Sub
End Class
答案 0 :(得分:0)
您可以将下载的HTML加载到HtmlDocument
对象
Dim htmlDoc As HtmlDocument = new HtmlDocument()
htmlDoc.LoadHtml(srRead.ReadToEnd)
加载HtmlDocument后。您可以使用Body
属性来访问Html正文。之后,您可以根据需要解析文档。