|
onlycxb 发表于 2014-10-15 23:12
复楼上,我是通过计算记录总数/每页20条记录得到总记录(代码中已经标注)。 网页数据地址为http://jiaoy ...
尝试用另外一种方法提取,代码如下:
Sub 新浪模拟交易2()
On Error Resume Next
Dim xml As New MSXML2.XMLHTTP, Js
Dim Url$, st$, n%, i%, r%, j%, Total%, m%, k%
Dim Sid As String
ActiveSheet.UsedRange.Offset(1, 0).Clear
For p = 1 To 2
Url = "http://jiaoyi.sina.com.cn/api/jsonp.php/Johansen=johansen062308384298872741413371443299/Ranking_Service.getRate?cid=10000&num=20&start=" & (p - 1) * 20 & "&orderby=profit_ratio&ordertype=desc&qjson="
With xml
.Open "GET", Url, False
.send
st = .responseText
End With
For i = 1 To 20
Cells((p - 1) * 20 + i + 1, 1) = Split(Split(st, "rank_day:")(i), ",mark:")(0)
Cells((p - 1) * 20 + i + 1, 2) = Split(Split(st, "name:")(i), ",rank_day")(0): Cells((p - 1) * 20 + i + 1, 2) = Mid((p - 1) * 20 + Cells(i + 1, 2), 2, Len(Cells((p - 1) * 20 + i + 1, 2)) - 2)
Cells((p - 1) * 20 + i + 1, 3) = Split(Split(st, "profit_ratio:")(i), ",profit_ratio_day")(0): Cells((p - 1) * 20 + i + 1, 3) = Mid(Cells((p - 1) * 20 + i + 1, 3), 2, Len(Cells((p - 1) * 20 + i + 1, 3)) - 2)
Cells((p - 1) * 20 + i + 1, 4) = Split(Split(st, "profit_ratio_day:")(i), ",profit_ratio_week")(0): Cells((p - 1) * 20 + i + 1, 4) = Mid(Cells((p - 1) * 20 + i + 1, 4), 2, Len(Cells((p - 1) * 20 + i + 1, 4)) - 2)
Cells((p - 1) * 20 + i + 1, 5) = Split(Split(st, "profit_ratio_week:")(i), ",success_ratio")(0): Cells((p - 1) * 20 + i + 1, 5) = Mid(Cells((p - 1) * 20 + i + 1, 5), 2, Len(Cells((p - 1) * 20 + i + 1, 5)) - 2)
Cells((p - 1) * 20 + i + 1, 6) = Split(Split(st, "success_ratio:")(i), ",retrace_rate")(0): Cells((p - 1) * 20 + i + 1, 6) = Mid(Cells((p - 1) * 20 + i + 1, 6), 2, Len(Cells((p - 1) * 20 + i + 1, 6)) - 2)
Cells((p - 1) * 20 + i + 1, 7) = Split(Split(st, "retrace_rate:")(i), ",frequency")(0): Cells((p - 1) * 20 + i + 1, 7) = Mid(Cells((p - 1) * 20 + i + 1, 7), 2, Len(Cells((p - 1) * 20 + i + 1, 7)) - 2)
Cells((p - 1) * 20 + i + 1, 8) = Split(Split(st, "frequency:")(i), ",holdstock:[")(0): Cells((p - 1) * 20 + i + 1, 8) = Mid(Cells((p - 1) * 20 + i + 1, 8), 2, Len(Cells((p - 1) * 20 + i + 1, 8)) - 2)
Cells((p - 1) * 20 + i + 1, 9) = Split(Split(st, "holdstock:[")(i), ",")(0): Cells((p - 1) * 20 + i + 1, 9) = Mid(Cells((p - 1) * 20 + i + 1, 9), 2, Len(Cells((p - 1) * 20 + i + 1, 9)) - 2)
Cells((p - 1) * 20 + i + 1, 10) = Split(Split(st, "profit_count:")(i), ",loss_count")(0): Cells((p - 1) * 20 + i + 1, 10) = Mid(Cells((p - 1) * 20 + i + 1, 10), 2, Len(Cells((p - 1) * 20 + i + 1, 10)) - 2)
Next i
Next p
End Sub
|
|