如何通过EXCEL VBA自动提取特定网页特定信息? excelvba是什么意思
如何利用VBA从多个excel文件中提取出含特定字段的数据
用open语句打开文件,然后应instr查找文本。如果字段是列,那直接找到列,然后用for循环查找就可以了
excel里面用vba中如何读取网页特定数据,可追加100分
供参考
Sub test()
Dim myQuery
With ActiveSheet
.Cells.Delete
.[a1] = "Conneting, Please Wait..."
Set myQuery = ActiveSheet.QueryTables _
.Add(Connection:="URL;www.boshi", _
Destination:=.Cells(1, 1))
End With
With myQuery
.Refresh
End With
补充:grhsc你不是知道读取全部网页的程序吗?那里可以先把整个网页以表格的方式读取到excel中,建立一个临时sheet,然后删除掉多余的数据,或者在excel中在读取需要的数据不就行了?
vba提取网页数据
下面的代码就可以:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
OptionExplicit
Sub批量获取网页内容()
Dimhttp, Pols, Arr, i, u
Sethttp = CreateObject("Microsoft.XMLHTTP")
i = 1
ForEachu InArray("url1", "url2")
http.Open "POST", u, False
http.send ""
Ifhttp.Status = 200 Then
Cells(i, 1) = http.responseText
i = i + 1
EndIf
Nextu
Sethttp = Nothing
EndSub
url1、url2就是你的网址,有多少写多少,每一个都要一http开头(然后是冒号和两个斜线)的完整地址。
Excel vba如何抓取指定的网页数据到单元格
参考:
Sub A1下载数据()
ReDim A2(1 To 200000, 1 To 15): A = 0
For i = 1 To 5
Sleep 2000 + 1000 * Rnd
With CreateObject("WinHttp.WinHttpRequest.5.1")
URL = "目标网页"
.Open "get", URL, False
.setRequestHeader "Host", "xxxxx"
.Send
Q1 = .responseText
Q1 = Replace(Q1, """", "")
Q1 = Replace(Q1, Chr(9), "")
Q1 = Replace(Q1, Chr(10), "")
Q1 = Replace(Q1, Chr(13), "")
Q1 = Replace(Q1, "=odd>", "=>")
End With
'Sheet1.[A2] = Q1
B1 = Split(Q1, "</tr><tr class=><td>")
For j = 1 To UBound(B1)
B2 = Split(B1(j), "</td>")
B3 = Split(Replace(B2(1), "<td>", ""), ",")
A2(A + 1, 1) = Replace(B2(2), "<td>", "")
A2(A + 1, 2) = Replace(B2(0), "<td>", "")
For K = 0 To 9
A2(A + 1, 3 + K) = B3(K)
Next
A = A + 1
Next
Application.StatusBar = i
Next
MsgBox A
With Sheet1
If .AutoFilterMode = True Then .AutoFilterMode = False
.Rows("2:600000").ClearContents
If A > 0 Then .[A2].Resize(A, 15) = A2
.Rows(1).AutoFilter '数据筛选
ActiveWindow.ScrollRow = 1
ActiveWindow.ScrollColumn = 1
End With
End Sub