|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 xiangbaoan 于 2018-8-18 11:25 编辑
Sub 交易数据()
Dim html, tb, url$, tp(), c%, r&, n%, i%, j%
[a:f] = ""
Application.ScreenUpdating = False
Set html = CreateObject("htmlfile")
r = 1
For n = 1 To 2
url = "http://vip.stock.finance.sina.com.cn/q/view/vFutures_History.php?page=" & n & "&breed=CL&start=2000-01-01&end=2018-08-16&jys=NYME&pz=CL&hy=&type=global&name=NYMEX原油"
With CreateObject("msxml2.xmlhttp")
.Open "GET", url, False
.send "text/html; charset=GB2312"
html.body.innerhtml = StrConv(.responsebody, vbUnicode)
End With
Set tb = html.all.tags("table")(3).Rows
ReDim tp(41, 5)
For i = 1 To tb.Length - 1
For j = 0 To tb(i).Cells.Length - 1
tp(i, j) = tb(i).Cells(j).innertext
Next
Next
With ActiveSheet
.Cells(r, 1).Resize(42, 6) = tp
r = .[a65536].End(3).Row + 1
End With
Next
Set html = Nothing: Set tb = Nothing
Application.ScreenUpdating = True
End Sub |
|