当前位置:首页 » 操作系统 » 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 浏览:594
制作脚本网站 发布: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 浏览:257
shell脚本入门案例 发布:2025-10-20 07:44:45 浏览:117
怎么上传照片浏览上传 发布:2025-10-20 07:44:03 浏览:808
python股票数据获取 发布:2025-10-20 07:39:44 浏览:714