|
给你换一个方法,这个应该不会出现其它字符了。
- 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 XmlDoc As Object, oNodes As Object, el, k%
- Dim rsArr()
-
- On Error Resume Next
- Set XmlDoc = CreateObject("Microsoft.XMLDOM")
- XmlDoc.async = "false"
- XmlDoc.Load ("http://kaijiang.500.com/static/info/kaijiang/xml/" & ShengFen & "k3/" & Format(dDate, "yyyymmdd") & ".xml")
-
- Set oNodes = XmlDoc.DocumentElement.ChildNodes
- If Err.Number > 0 Then
- ReDim rsArr(1 To 1, 1 To 3)
- GoTo TheEnd
- End If
-
- ReDim rsArr(1 To oNodes.Length, 1 To 3)
- For Each el In oNodes
- k = k + 1
- rsArr(k, 1) = el.Attributes(0).Text
- rsArr(k, 2) = el.Attributes(2).Text
- rsArr(k, 3) = el.Attributes(1).Text
- Next
- TheEnd:
- getDataFromWebByDate = rsArr
- End Function
复制代码 |
评分
-
1
查看全部评分
-
|