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閲岀殑缃戦〉婧愮爜銆