.net瀏覽器源代碼vb,net 代碼

VB怎么獲取網(wǎng)頁源碼

1)使用MICROSOFT INTERNET TRANSFER CONTROL的,代碼如下:

為企業(yè)提供做網(wǎng)站、成都網(wǎng)站建設(shè)、網(wǎng)站優(yōu)化、營銷型網(wǎng)站、競價(jià)托管、品牌運(yùn)營等營銷獲客服務(wù)。成都創(chuàng)新互聯(lián)擁有網(wǎng)絡(luò)營銷運(yùn)營團(tuán)隊(duì),以豐富的互聯(lián)網(wǎng)營銷經(jīng)驗(yàn)助力企業(yè)精準(zhǔn)獲客,真正落地解決中小企業(yè)營銷獲客難題,做到“讓獲客更簡單”。自創(chuàng)立至今,成功用技術(shù)實(shí)力解決了企業(yè)“網(wǎng)站建設(shè)、網(wǎng)絡(luò)品牌塑造、網(wǎng)絡(luò)營銷”三大難題,同時(shí)降低了營銷成本,提高了有效客戶轉(zhuǎn)化率,獲得了眾多企業(yè)客戶的高度認(rèn)可!

Dim strhtml As String

Dim STRURL As String

STRURL=""

strhtml = Inet1.OpenURL(STRURL)

2)用System.Net命空間下的HttpWebRequest來取得,代碼如下:

Dim url As String=" " ' 網(wǎng)址

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 ' 獲取或設(shè)置一個(gè)值,該值指示是否與 Internet資源建立持久連接。

Dim reader As StreamReader = _

New StreamReader(httpResp.GetResponseStream,

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

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

如何用vb.net獲得網(wǎng)頁的源代碼

Dim url As String=" 網(wǎng)址"

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 ' 獲取或設(shè)置一個(gè)值,該值指示是否與

Internet資源建立持久連接。

Dim reader As StreamReader = _

New StreamReader(httpResp.GetResponseStream,

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

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

如何用vb.net獲取網(wǎng)頁源代碼

使用webbrowser控件來加載網(wǎng)頁,然后再 Private Sub WebBrowser1_DocumentCompleted下通過使用WebBrowser1.Document.Body.InnerHtml 來獲取網(wǎng)頁的源代碼,或使用 WebBrowser1.Document.Body.InnerText來獲取網(wǎng)頁中的文本。之后可以通過字符串控制指令或者正則表達(dá)式來精確獲取到你所需的數(shù)據(jù)。

網(wǎng)頁標(biāo)題:.net瀏覽器源代碼vb,net 代碼
本文URL:http://muchs.cn/article30/phgjso.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App設(shè)計(jì)、移動(dòng)網(wǎng)站建設(shè)網(wǎng)站導(dǎo)航、服務(wù)器托管、定制開發(fā)網(wǎng)站策劃

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都做網(wǎng)站