本帖最后由 renahu 于 2014-11-9 14:20 编辑
引子玄 发表于 2014-11-1 20:15
学好了就好,我给个题目,测试你学得如何?请接题——
这个网页里的“大小盘走势”指数,用fiddler方法如 ... - Sub 大小球盘口() '练习五
- Dim strText$, arr, brr, crr(), drr(), err(), lab As Boolean, trr, ds
- Set ds = CreateObject("scripting.dictionary")
- Cells.Clear
- [a:f].HorizontalAlignment = xlCenter
- [a1:f1].Font.ColorIndex = 2
- [a1:f1].Interior.Color = RGB(25, 156, 223)
- Range("b1:b65536").NumberFormatLocal = "0.000"
- Range("d1:d65536").NumberFormatLocal = "0.000"
- Range("e1:e65536").NumberFormatLocal = "mm-dd hh:mm:ss"
- Top = Array("序", "大球", "大小球盘口", "小球", "变化时间", "状态")
- [a1].Resize(1, 6) = Top
- ActiveWindow.DisplayGridlines = True
- With CreateObject("MSXML2.XMLHTTP")
- .Open "GET", "http://fenxi.310v.net/odds_pic/panlu.html?match_id=939357&company_id=397", False
- .send
- strText = Split(Split(.responseText, "var BPK = [];")(1), "function sort_pk(d1,d2)")(0)
- strText = Left(strText, Len(strText) - 3)
- arr = Split(strText, ";")
- For i = 0 To UBound(arr)
- arr(i) = Replace(Replace(arr(i), "BPK[" & i + Split(Split(arr(i), "BPK[")(1), "]")(0) - i & "]=[", ""), "]", "")
- arr(i) = Right(arr(i), Len(arr(i)) - 1)
- ReDim Preserve drr(i)
- drr(i) = Split(arr(i), ",")(1)
- ReDim Preserve err(i)
- err(i) = Mid(Split(arr(i), ",")(0), 2, Len(Split(arr(i), ",")(0)) - 2)
- Next
- For i = 0 To UBound(err)
- ds(err(i)) = drr(i)
- Next
- .Open "GET", "http://fenxi.310v.net/data/panlu/panlu/939/b939357_397.js?d=1414914106552 ", False
- .send
- strText = Split(.responseText, "d3=[];")(1)
- strText = Left(strText, Len(strText) - 2)
- brr = Split(strText, ";")
- brr(0) = Replace(brr(0), "d3[0]=", "d3.push(") & ")"
- For i = 0 To UBound(brr)
- brr(i) = Replace(Replace(brr(i), "d3.push(""", ""), """)", "")
- brr(i) = Right(brr(i), Len(brr(i)) - 1)
- ReDim Preserve crr(0 To UBound(brr), 0 To 5)
- crr(i, 0) = i + 1
- For x = 0 To 4
- crr(i, x + 1) = Split(brr(i), ",")(x)
- Next
- crr(i, 2) = err(crr(i, 2) - 1) & "球"
- If i > 0 Then
- If ds(Split(crr(i, 2), "球")(0)) > ds(Split(crr(i - 1, 2), "球")(0)) Then
- crr(i, 2) = crr(i, 2) & " 升"
- ElseIf ds(Split(crr(i, 2), "球")(0)) < ds(Split(crr(i - 1, 2), "球")(0)) Then
- crr(i, 2) = crr(i, 2) & " 降"
- End If
- If crr(i, 5) = 1 Then
- crr(i, 5) = ""
- ElseIf crr(i, 5) = 3 And crr(i - 1, 5) = "" And lab = False Then
- crr(i, 5) = "即"
- ElseIf crr(i, 5) = 3 And crr(i - 1, 5) = "即" Then
- crr(i, 5) = "临"
- ElseIf crr(i, 5) = 3 And crr(i - 1, 5) = "临" Then
- crr(i, 5) = "": lab = True
- ElseIf crr(i, 5) = 3 And lab = True Then
- crr(i, 5) = ""
- End If
- Else
- crr(i, 5) = "早"
- End If
- Next
- '颠倒顺序
- trr = crr
- For i = UBound(crr) To 0 Step -1
- m = m + 1
- For j = 0 To UBound(crr, 2)
- trr(m - 1, j) = crr(i, j)
- Next
- Next
- End With
- Sheet1.[a2].Resize(UBound(trr) + 1, 6) = trr
- '设置颜色
- For j = 0 To UBound(trr, 2)
- Select Case j
- Case 1
- For i = UBound(trr) - 1 To 0 Step -1
- If trr(i, j) > trr(i + 1, j) Then
- Cells(i + 2, j + 1).Font.ColorIndex = 1
- Cells(i + 2, j + 1).Interior.Color = RGB(255, 223, 223)
- ElseIf trr(i, j) < trr(i + 1, j) Then
- Cells(i + 2, j + 1).Font.ColorIndex = 1
- Cells(i + 2, j + 1).Interior.Color = RGB(196, 255, 196)
- End If
- Next
- Case 2
- For i = UBound(trr) - 1 To 0 Step -1
- If Right(trr(i, j), 1) = "升" Then
- Cells(i + 2, j + 1).Font.ColorIndex = 1
- Cells(i + 2, j + 1).Interior.Color = RGB(255, 223, 223)
- Cells(i + 2, j + 1).Characters(Start:=Len(Cells(i + 2, j + 1)), Length:=1).Font.ColorIndex = 3
- ElseIf Right(trr(i, j), 1) = "降" Then
- Cells(i + 2, j + 1).Font.ColorIndex = 1
- Cells(i + 2, j + 1).Interior.Color = RGB(196, 255, 196)
- Cells(i + 2, j + 1).Characters(Start:=Len(Cells(i + 2, j + 1)), Length:=1).Font.ColorIndex = 32
- End If
- Next
- Case 3
- For i = UBound(trr) - 1 To 0 Step -1
- If trr(i, j) > trr(i + 1, j) Then
- Cells(i + 2, j + 1).Font.ColorIndex = 1
- Cells(i + 2, j + 1).Interior.Color = RGB(255, 223, 223)
- ElseIf trr(i, j) < trr(i + 1, j) Then
- Cells(i + 2, j + 1).Font.ColorIndex = 1
- Cells(i + 2, j + 1).Interior.Color = RGB(196, 255, 196)
- End If
- Next
- Case 5
- For i = UBound(trr) To 0 Step -1
- If trr(i, j) = "早" Then
- Cells(i + 2, j + 1).Font.ColorIndex = 2
- Cells(i + 2, j + 1).Interior.ColorIndex = 32
- ElseIf trr(i, j) = "即" Then
- Cells(i + 2, j + 1).Font.ColorIndex = 2
- Cells(i + 2, j + 1).Interior.ColorIndex = 3
- ElseIf trr(i, j) = "临" Then
- Cells(i + 2, j + 1).Font.ColorIndex = 2
- Cells(i + 2, j + 1).Interior.ColorIndex = 10
- End If
- Next
- End Select
- Next
- '画表格线
- Cells.Borders.LineStyle = xlNone
- With Range("a1:f" & Range("a65536").End(xlUp).Row).Borders
- .LineStyle = xlContinuous
- .Weight = xlThin
- .ColorIndex = xlAutomatic
- End With
-
- End Sub
复制代码 我在 blanksoul12 的基础上进行了精细化,并完全按照网上的格式和内容显示,几乎完全一样了。这抓的够全吧 |