vbwebbrowser網頁源碼
㈠ 如何用vb webbrowser獲取帶框架網頁的全部源代碼
用vb webbrowser獲取帶框架網頁的全部源代碼,指令如下:
WebBrowser1.Document.frames(0).Document.documentElement.outerHTML
遍歷框架就可以得到所有的(WebBrowser1.Document.frames(0).count框架個數)。
㈡ vb 如何在WebBrowser控制項中修改網頁源碼,達到自動登錄的效果
設置一下
WebBrowser(WebBrowser1)的屬性吧
Private
Sub
Form_Load()WebBrowser1.Navigate
("源碼來源的網址")WebBrowser1 .Document.all("username").value
=
你的賬戶WebBrowser1 .Document.all("password").value
=
你的密碼End
Sub
Private
Sub
Command1_Click()WebBrowser1 .Document.all("submit")。clickEnd
Sub
㈢ VB如何獲取webbrowser源碼指定文本
第一個紅框的文本:
WebBrowser1.Document.getElementById("list_uin").getElementsByTagName("label")(0).innerText
第二個紅框的文本:
WebBrowser1.Document.getElementById("list_uin").getElementsByTagName("label")(1).innerText
㈣ 用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
㈤ 濡備綍鐢╲b.net鑾峰彇緗戦〉婧愪唬鐮
浣跨敤webbrowser鎺т歡鏉ュ姞杞界綉欏碉紝鐒跺悗鍐 Private Sub WebBrowser1_DocumentCompleted涓嬮氳繃浣跨敤WebBrowser1.Document.Body.InnerHtml 鏉ヨ幏鍙栫綉欏電殑婧愪唬鐮侊紝鎴栦嬌鐢 WebBrowser1.Document.Body.InnerText鏉ヨ幏鍙栫綉欏典腑鐨勬枃鏈銆備箣鍚庡彲浠ラ氳繃瀛楃︿覆鎺у埗鎸囦護鎴栬呮e垯琛ㄨ揪寮忔潵綺劇『鑾峰彇鍒頒綘鎵闇鐨勬暟鎹銆
㈥ vb WebBrowser1緗戦〉婧愮爜 涓嶅畬鏁
娌″繀瑕佺敤 createtextrange銆
鐩存帴
WebBrowser1.document.documentElement.outerHTML
鎴栬
WebBrowser1.document.all(0).outerHTML
灝辮兘鑾峰彇婧愮爜浜嗐
涓嶈繃榪欎簺閮芥槸涓嶅寘鍚宓屽楀湪鍐呯殑frame閲岀殑緗戦〉婧愮爜銆