導航:首頁 > 編程語言 > vbnet網頁源代碼

vbnet網頁源代碼

發布時間:2025-01-20 23:06:19

『壹』 如何使用vb.net來解析網頁源代碼,最終獲取所需數據

使用webbrowser控制項來載入網頁,然後再 Private Sub WebBrowser1_DocumentCompleted下通過使用WebBrowser1.Document.Body.InnerHtml 來獲取網頁的源代碼,或使用 WebBrowser1.Document.Body.InnerText來獲取網頁中的文本。之後可以通過字元串控制指令或者正則表達式來精確獲取到你所需的數據。

『貳』 VB.NET 不使用控制項獲取某網頁源代碼

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim MyClient As Net.WebClient = New Net.WebClient
Dim MyReader As New System.IO.StreamReader(MyClient.OpenRead("http://wap..com"), System.Text.Encoding.Default)
Dim MyWebCode As String = MyReader.ReadToEnd
Me.RichTextBox1.Text = MyWebCode
MyReader.Close()
End Sub

『叄』 VB.NET如何使用正則表達式讀取網頁源碼中的指定內容

<divclass="cont">[sS]*?href=["']?([^"']*)["']?[sS]*?title=["']?([^"]*)["']?

『肆』 如何用vb.net獲得網頁的源代碼

Dim url As String=" 網址"

Dim httpReq As System.Net.HttpWebRequest

Dim httpResp As System.Net.HttpWebResponse

Dim httpURL As New System.Uri(url)

httpReq = CType(WebRequest.Create(httpURL), HttpWebRequest)

httpReq.Method = "GET"

httpResp = CType(httpReq.GetResponse(), HttpWebResponse)

httpReq.KeepAlive = False ' 獲取或設置一個值,該值指示是否與
Internet資源建立持久連接。

Dim reader As StreamReader = _

New StreamReader(httpResp.GetResponseStream,

System.Text.Encoding.GetEncoding(-0))

Dim respHTML As String = reader.ReadToEnd() 'respHTML就是網頁源代碼

『伍』 vb.NET webbrowser 修改網頁源碼

Dim c
Private Sub Form_Load()
URL = "http://..com/question/123100932.html"
c = 0
WebBrowser1.Navigate URL
End Sub

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If c = 1 Then Exit Sub '這個是為了防止這個過程無限執行下去
c = c + 1
tmp = WebBrowser1.Document.body.innerhtml
tmp = Replace(tmp, "88753967", "好玩嗎?")
WebBrowser1.Document.body.innerhtml = tmp
End Sub

閱讀全文

與vbnet網頁源代碼相關的資料

熱點內容
用phpcms建網站流程 瀏覽:973
word2010表格數字遞增 瀏覽:273
資料庫表的大小 瀏覽:452
天津編程考試哪裡好 瀏覽:792
蘋果手機更新系統後系統文件過大 瀏覽:810
js的事件有什麼區別 瀏覽:763
圖片中植入程序 瀏覽:832
數控機床編程哪裡能學 瀏覽:110
網頁源代碼的視頻 瀏覽:684
java獲取button的名字 瀏覽:64
ps人物彩繪攝影教程 瀏覽:70
c獲取當前文件名 瀏覽:212
3dmax9怎麼打開文件 瀏覽:965
iphone刪除的app還在 瀏覽:100
ug編程怎麼復制圖層 瀏覽:980
keil中自己編寫c語言頭文件 瀏覽:261
xp換成win7後文件只讀 瀏覽:279
檢測數據是什麼 瀏覽:151
如何編程製造游戲 瀏覽:791
電腦文件快捷鍵 瀏覽:793

友情鏈接