|
Sub 財富財經日曆財經會議數據()
Dim JsStr As String
Dim Js As String
Dim tmpStr As String
Dim i As Integer
Dim nPage As Byte
Dim nRow As Integer
ThisWorkbook.ActiveSheet.Cells.Clear
JsStr = "http://data.eastmoney.com/DataCenter_V3/cjrl/getData.ashx?&pagesize=50&page=1&js=var o&sortRule=1&sortType=ConferenceDate&startDateTime=2017-10-02&endDateTime=2017-10-31&Type=cjhy&rt=50239938"
With CreateObject("WinHttp.WinHttpRequest.5.1")
.Open "GET", JsStr, False
.setrequestheader "Referer", "http://data.eastmoney.com/cjrl/default.html"
.send
JsStr = .responsetext
End With
tmpStr = JsStr & ";"
With CreateObject("MSScriptControl.ScriptControl")
.Language = "JScript"
.addcode tmpStr
nPage = .Eval("o.pages")
End With
nRow = 0
For i = 1 To nPage
JsStr = "http://data.eastmoney.com/DataCenter_V3/cjrl/getData.ashx?&pagesize=50&page=" & i & "&js=var o&sortRule=1&sortType=ConferenceDate&startDateTime=2017-10-02&endDateTime=2017-10-31&Type=cjhy&rt=50239938"
With CreateObject("WinHttp.WinHttpRequest.5.1")
.Open "GET", JsStr, False
.setrequestheader "Referer", "http://data.eastmoney.com/cjrl/default.html"
.send
JsStr = .responsetext
End With
Js = "var r,k,row=c=1,d={};for(r in j){row++;for(k in j[r]){if(!d[k]){d[k]=c++;rng(1,d[k])=k;}rng(row,d[k])= j[r][k];}}"
Js = "j=" & Split(Split(JsStr, "data"":")(1), "]")(0) & "]" & ";" & Js
With CreateObject("MSScriptControl.ScriptControl")
.Language = "JScript"
.AddObject "rng", ThisWorkbook.ActiveSheet.Range("A" & nRow + 1)
.Eval (Js)
End With
If i <> 1 Then
With ThisWorkbook.ActiveSheet
.Rows(nRow + 1).Delete
nRow = .Range("A65536").End(xlUp).Row
End With
Else
nRow = ThisWorkbook.ActiveSheet.Range("A65536").End(xlUp).Row
End If
Next i
ThisWorkbook.ActiveSheet.Columns("A:R").AutoFit
End Sub |
评分
-
1
查看全部评分
-
|