|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub Main()
- Dim StDate As Date, EndDate As Date, tempDate As Date, ShengFen$
- Dim rsArr()
-
- Range("A5:C" & Cells(Rows.Count, 1).End(xlUp).Row + 1).ClearContents
-
- ShengFen = [B1].Value
- ShengFen = Mid(ShengFen, InStrRev(ShengFen, "/") + 1)
- ShengFen = Left(ShengFen, InStr(ShengFen, "k3.") - 1)
- StDate = Format("20" & Left([B2].Value, 6), "0000/00/00")
- EndDate = Format("20" & Left([B3].Value, 6), "0000/00/00")
-
- tempDate = EndDate
- Do
- rsArr = getDataFromWebByDate(tempDate, ShengFen)
- Range("A" & Cells(Rows.Count, 1).End(xlUp).Row + 1).Resize(UBound(rsArr), 3) = rsArr
- tempDate = tempDate - 1
- Loop Until tempDate < StDate
-
- End Sub
- Function getDataFromWebByDate(dDate As Date, ShengFen As String)
- Dim strText As String, arr, brr, rsArr(), i%, j%
-
- With CreateObject("MSXML2.XMLHTTP")
- .Open "GET", "http://kaijiang.500.com/static/info/kaijiang/xml/" & ShengFen & "k3/" & Format(dDate, "yyyymmdd") & ".xml", False
- .Send
- strText = .responsetext
- End With
-
- If InStr(strText, "404 Not Found") Then
- ReDim rsArr(1 To 1, 1 To 3)
- GoTo TheEnd
- End If
-
- strText = Replace(strText, " expect=""", "|")
- strText = Replace(strText, """ opencode=""", "|")
- strText = Replace(strText, """ opentime=""", "|")
- strText = Replace(strText, Chr(10), "")
- strText = Replace(strText, """ />", "")
-
- arr = Split(strText, "<row")
- ReDim rsArr(1 To UBound(arr), 1 To 3)
- For i = 1 To UBound(arr)
- brr = Split(arr(i), "|")
- rsArr(i, 1) = brr(1)
- rsArr(i, 2) = brr(3)
- rsArr(i, 3) = brr(2)
- Next
- TheEnd:
- getDataFromWebByDate = rsArr
- End Function
复制代码 |
评分
-
1
查看全部评分
-
|