我想知道你是否阅读某个div中的文字,所以当html代码说:
<html>
<head>
</head>
<body>
<div id="t" class="tee-tools" contenteditable="true" data-placeholder="Write a message (Enter to send)">xxxx</div>
</body>
</html>
在代码
中获取xxxx等文本答案 0 :(得分:0)
首先需要HTMLAgilityPack.Dll。
Imports System.Net
Imports System.IO
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim page As String = GetPage("http://qrspace.com/rere.html")
Dim dokuman = New HtmlAgilityPack.HtmlDocument()
dokuman.LoadHtml(GetPage(page))
Dim title As HtmlAgilityPack.HtmlNodeCollection = dokuman.DocumentNode.SelectNodes("//div[@class='tee-tools']")
For Each titles In title
MsgBox(titles.InnerText)
'If titles.InnerText = "xxxx" Then
'blablabla
'End If
Next
End Sub
Function GetPage(ByVal pageUrl As String) As String
Dim s As String = pageUrl
Try
Dim request As HttpWebRequest = WebRequest.Create(s)
Dim response As HttpWebResponse = request.GetResponse()
Using reader As StreamReader = New StreamReader(response.GetResponseStream())
s = reader.ReadToEnd()
End Using
Catch ex As Exception
End Try
Return s
End Function
End Class