|
Sub 抓取网页数据()
Dim xmlhttp As Object, arr(1 To 10000, 1 To 3), D As Object, W As Object
Set D = CreateObject("Htmlfile"): Set W = D.parentWindow
Set xmlhttp = CreateObject("msxml2.xmlhttp")
Cells.Clear: [a1:c1] = [{"股票代码","名称","所属行业"}]
For j = 1 To 2 '抓取页码,本例抓2页试试!
xmlhttp.Open "GET", "http://nufm.dfcfw.com/EM_Finance2014NumericApplication/JS.aspx/JS.aspx?type=ct&st=(FFRank)&sr=1&p=" & j & "&ps=50&js=var%20fLXgtErK={pages:(pc),data:[(x)]}&token=894050c76af8597a853f5b408b759f5d&cmd=C._AB&sty=DCFFITAM&rt=49886027", False
xmlhttp.send
Do While xmlhttp.readyState <> 4
DoEvents
Loop
W.execScript xmlhttp.responseText & ";a=fLXgtErK.data;l=a.length"
For i = 0 To W.l - 1
n = n + 1
arr(n, 1) = "'" & Split(W.eval("a[" & i & "]"), ",")(1)
arr(n, 2) = Split(W.eval("a[" & i & "]"), ",")(2)
arr(n, 3) = Split(W.eval("a[" & i & "]"), ",")(13)
Next
Next
Range("a2").Resize(n, 3) = arr
End Sub |
评分
-
1
查看全部评分
-
|