|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub Main()
- Dim StDate As Date, EndDate As Date, tempDate As Date
- Dim rsArr()
-
- Range("A5:C" & Cells(Rows.Count, 1).End(xlUp).Row + 1).ClearContents
-
- StDate = Format("20" & Left([B2].Value, 6), "0000/00/00")
- EndDate = Format("20" & Left([B3].Value, 6), "0000/00/00")
-
- tempDate = StDate
- Do
- rsArr = getDataFromWebByDate(tempDate)
- Range("A" & Cells(Rows.Count, 1).End(xlUp).Row + 1).Resize(UBound(rsArr), 3) = rsArr
- tempDate = tempDate + 1
- Loop Until tempDate > EndDate
-
- End Sub
- Function getDataFromWebByDate(dDate As Date)
- Dim strText As String, arr, brr, rsArr(), i%, j%
-
- With CreateObject("MSXML2.XMLHTTP")
- .Open "GET", "http://kaijiang.500.com/static/info/kaijiang/xml/jsk3/" & 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
查看全部评分
-
|