當前位置:首頁 » 操作系統 » vb獲取webbrowser源碼

vb獲取webbrowser源碼

發布時間: 2023-03-05 01:52:30

1. VB如何獲取webbrowser源碼指定文本

第一個紅框的文本:
WebBrowser1.Document.getElementById("list_uin").getElementsByTagName("label")(0).innerText

第二個紅框的文本:
WebBrowser1.Document.getElementById("list_uin").getElementsByTagName("label")(1).innerText

2. 如何用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就是網頁源代碼

3. VB WebBrowser 獲取網頁內容~

private
sub
command1_click()
set
vdocs
=
webbrowser1.document.getelementsbytagname("ul")
text1.text
=
vdocs(32).innertext
end
sub
不過,你既然都打開網頁了,已經看到了,還提取它干什麼?
如果你是想用軟體自動提取這個信息,到其它地方用。那就不要用webbrowser,這個太慢。直接用
inet控制項,或者用xmlhttp等獲取源碼再取信息。

4. 如何用vb webbrowser獲取帶框架網頁的全部源代碼

用vb webbrowser獲取帶框架網頁的全部源代碼,指令如下:

WebBrowser1.Document.frames(0).Document.documentElement.outerHTML

遍歷框架就可以得到所有的(WebBrowser1.Document.frames(0).count框架個數)。

5. VB 獲取網頁源碼 你的這個是怎麼解決的.能和我說一下嗎.謝謝

1、提取:用這個vb小程序可以!

6. 用vb獲取任一網頁源代碼,要完整的!!!,可以用webbrowser控制項

'你把下面的代碼保存為Form1.frm,然後雙擊打開該文件,運行後按提示即可看到結果。
'呵呵,夠詳細了,再不會我也沒辦法了。

'====文件Form1.frm====

VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 5265
ClientLeft = 60
ClientTop = 450
ClientWidth = 9000
LinkTopic = "Form1"
ScaleHeight = 5265
ScaleWidth = 9000
StartUpPosition = 3 '窗口預設
Begin VB.TextBox Text2
Height = 3735
Left = 120
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 2
Top = 480
Width = 8655
End
Begin VB.TextBox Text1
Height = 270
Left = 2040
TabIndex = 1
Text = "我的家"
Top = 120
Width = 4095
End
Begin VB.CommandButton Command1
Caption = "獲取HTML源碼"
Height = 615
Left = 3480
TabIndex = 0
Top = 4440
Width = 1575
End
Begin VB.Label Label2
Caption = "注意:獲取源碼之前必須先用IE打開網址,然後輸入窗口標題關鍵字。如www.51.com的標題關鍵字是:我的家"
Height = 615
Left = 240
TabIndex = 4
Top = 4440
Width = 3135
End
Begin VB.Label Label1
Caption = "請輸入IE窗口標題:"
Height = 255
Left = 120
TabIndex = 3
Top = 120
Width = 1815
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Function GetIeHtml(IeTitle As String) As String
Dim oShellApp: Set oShellApp = CreateObject("Shell.Application")
Dim oShellAppWindows: Set oShellAppWindows = oShellApp.Windows
Dim owin

'獲取彈出的IE窗口
For Each owin In oShellAppWindows '獲取彈出的IE窗口
If LCase(TypeName(owin.Document)) = "htmldocument" And _
InStr(1, owin.LocationName, IeTitle, vbTextCompare) > 0 Then '如果找到符合條件的IE窗口
GetIeHtml = owin.Document.activeElement.Document.documentElement.innerHTML '此句可獲得完整html代碼
GoTo Mend '退出
End If
Next

Mend:
Set oShellAppWindows = Nothing
Set oShellApp = Nothing
Set owin = Nothing

End Function

Private Sub Command1_Click()
Dim S As String
S = GetIeHtml(Text1.Text) '表示獲得標題含有"我的家"的html代碼
Text2.Text = S
End Sub

Private Sub Form_Load()
'Shell "explorer.exe ""http://www.51.com/""", vbNormalNoFocus
End Sub

熱點內容
java返回this 發布:2025-10-20 08:28:16 瀏覽:595
製作腳本網站 發布:2025-10-20 08:17:34 瀏覽:889
python中的init方法 發布:2025-10-20 08:17:33 瀏覽:583
圖案密碼什麼意思 發布:2025-10-20 08:16:56 瀏覽:766
怎麼清理微信視頻緩存 發布:2025-10-20 08:12:37 瀏覽:686
c語言編譯器怎麼看執行過程 發布:2025-10-20 08:00:32 瀏覽:1015
郵箱如何填寫發信伺服器 發布:2025-10-20 07:45:27 瀏覽:258
shell腳本入門案例 發布:2025-10-20 07:44:45 瀏覽:117
怎麼上傳照片瀏覽上傳 發布:2025-10-20 07:44:03 瀏覽:808
python股票數據獲取 發布:2025-10-20 07:39:44 瀏覽:714