|
wcymiss 发表于 2014-10-21 15:20
新手作业:
网站:http://www.pinble.com/Lottery.htm
操作:点击“各省体彩”---“江苏七星彩”,获取江 ...
新手作业- Sub 江苏七星彩()
- Dim objhq As New WinHttp.WinHttpRequest
- Dim STxt As String, Url As String, i As Integer, j As Integer
- Dim Pages As Integer, Pstr As String, arr, brr, rng As Range
- Cells.Clear
- With objhq
- .Open "POST", "http://www.pinble.com/Template/WebService1.asmx/Present3DList", False
- .SetRequestHeader "Content-Type", "application/json; charset=UTF-8"
- .SetRequestHeader "Referer", "http://www.pinble.com/Lottery.htm"
- .Send "{pageindex:'1',lottory:'TC7XCData_jiangS',pl3:'',name:'江苏七星彩',isgp: '0'}"
- STxt = .ResponseText
- End With
- STxt = UTF8toChineseCharacters(STxt) 'J3编码
- Pages = Split(Split(Split(STxt, "分页")(1), "页")(0), "/")(1)
- '循环各页取数,下面以取2页为例 ,实际总页数Pages
- For i = 1 To 2
- With objhq
- .Open "POST", "http://www.pinble.com/Template/WebService1.asmx/Present3DList", False
- .SetRequestHeader "Content-Type", "application/json; charset=UTF-8"
- .SetRequestHeader "Referer", "http://www.pinble.com/Lottery.htm"
- .Send "{pageindex:'" & i & "',lottory:'TC7XCData_jiangS',pl3:'',name:'江苏七星彩',isgp: '0'}"
- STxt = UTF8toChineseCharacters(.ResponseText)
- End With
- Cells(1, 1) = "江苏七星彩 开奖信息": Cells(1, 2) = "开奖周期:周二、周四、周五、周日"
- Cells(2, 1).Resize(1, 3) = Array("开奖时间", "期号", "开奖号码")
- Pstr = "<tr style='backgro%und-color: White; border-color: #B6CBE8;'>"
- arr = Split(STxt, Pstr)
- ReDim brr(1 To UBound(arr) - 1, 1 To 3)
- For j = 1 To UBound(arr) - 1
- brr(j, 1) = Split(Split(arr(j), "</td>")(0), ">")(1)
- brr(j, 2) = Split(Split(arr(j), "</td>")(1), ">")(1)
- brr(j, 3) = Split(Split(Split(arr(j), "</td>")(2), "</span>")(0), "ctl02_lblHao'>")(1)
- Next j
- Set rng = Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
- rng.Resize(UBound(brr, 1), 3) = brr
- Next i
- Columns("A:A").NumberFormatLocal = "yyyy-m-d"
- Columns("B:C").NumberFormatLocal = "@"
- Columns("A:C").EntireColumn.AutoFit
- End Sub
- Function UTF8toChineseCharacters(szInput)
- With CreateObject("MSScriptControl.ScriptControl")
- .Language = "JavaScript"
- .AddCode "function decode(str){return unescape(str.replace(/\u/g,'%u'));}"
- UTF8toChineseCharacters = .Eval("decode('" & szInput & "')")
- End With
- End Function
复制代码 |
|