|
- Sub 挣钱不易理性购买()
- Dim byteData, vData, results(), vTemp
- Dim strURL As String, strText As String, x As Long, y As Long
-
- ' strURL = "http://data.17500.cn/ssq_asc.txt" 'http://data.917500.cn/cqssc_10000.txt
- ' strURL = "http://data.17500.cn/dlt_asc.txt" 'http://data.17500.cn/dlt_desc.txt
- ' strURL = "http://data.17500.cn/7xc_asc.txt"
- ' strURL = "http://data.17500.cn/3d_asc.txt"
- ' strURL = "http://data.17500.cn/7lc_asc.txt"
- strURL = "http://data.17500.cn/pl5_asc.txt"
- ' strURL = "http://data.17500.cn/ssq_desc.txt" ' "http://data.17500.cn/ssq_asc.txt"
-
- With CreateObject("Msxml2.XMLHTTP")
- .Open "GET", strURL, False
- .Send
- byteData = .ResponseBody
- End With
- With CreateObject("ADODB.Stream")
- .Type = 1 '1-二进制,2-文本
- .Mode = 3 '1-读,2-写,3-读写
- .Open
- .Write byteData '二进制数组写入ADODB.Stream对象
- .Position = 0 '数据流位置,表示数据操作从这里开始,第一个位置的值为0,不是 1
- .Type = 2 '1-二进制,2-文本
- .Charset = "UTF-8" '数据的编码方式,可选值:ASCII,GB2312
- strText = .ReadText 'ReadText([长度]) 从 Stream 对象中读取文本数据,不指定长度表示全部读取
- .Close
- End With
- vData = Split(strText, Chr(10))
- ReDim results(0 To UBound(vData), 0 To 28)
- For y = 0 To UBound(results)
- vTemp = Split(vData(y), Chr(32))
- For x = 0 To UBound(vTemp)
- results(y, x) = vTemp(x)
- Next
- Next
- Cells.Clear
- Range("A2").Resize(UBound(results) + 1, UBound(results, 2) + 1) = results
- End Sub
复制代码 |
|