问题描述
- VB获取网页源码,高手指导!
-
Private Sub Command4_Click() '
On Error Resume Next
Dim baiIE As Object
For Each baiIE In dWinFolder
If InStr(1, baiIE.FullName, "", vbTextCompare) <> 0 Then
If InStr(1, baiIE.LocationURL, "www.taobao.com", vbTextCompare) <> 0 Then
Exit For
End If
End If
Next
MyArray = Split(getyuanma(baiIE.LocationURL), "订单号:") '跟列订单
For P = 1 To UBound(MyArray)
Text1.Text = Text1.Text & "/////" & MyArray(P)
Next P
End SubPublic Function getyuanma(URL)
On Error Resume Next
Dim objDoc As Object
Dim objIE As Object
For Each objIE In dWinFolder
If objIE.LocationURL = URL Then
Set objDoc = objIE.Document
For I = 1 To objDoc.All.length - 1
If objDoc.All(I).tagname = "BODY" Then
getyuanma = objDoc.All(I).innerText
End If
Next
Exit For
End If
Next
End Function以上代码为获取访问包含“www.taobao.com”网页IE浏览器源代码,但是有的电脑上可以,有的不行,请高手指教!
解决方案
dWinFolder在哪里定义的,你的这段代码依赖本机是否安装了IE,以及IE是否是默认的浏览器,尽量在原版的xp上运行。
时间: 2024-11-30 20:20:28