|
http://www.shdjt.com/sort.asp 这个也做好了
代码如下,excel如附件,你测试下。
本工具还能依据你所输入需要数据的日期进行采集。- Option Explicit
- Sub Test()
- Dim tmp() As String, i As Integer, arr() As String, d As String, p As Integer, n As Long, xmlhttp As Object, sh As Worksheet
-
- d = Format(Worksheets(1).Cells(10, 4).Value, "yyyy-mm-dd")
-
- Set sh = Sheets.Add(AFTER:=Worksheets(1))
- sh.Name = Format(Now, "采集时间yyyy年mm月dd日hh时NN分")
- sh.[a1:AL1] = Split("序,日期,更新时间,股票代码,股票名称,最新,涨幅,ddx,ddy,ddz,主动率,通吃率,股价涨速1分钟,5日ddx,5日ddy,60日ddx,60日ddy,ddx10(次),ddx10(连),特大差,大单差,中单差,小单差,活跃度,单数比,特大买入,特大卖出,大单买入,大单卖出,中单买入,中单卖出,小单买入,小单卖出,换手率,买卖差,量比,每股收益,股票名称", ",")
-
- For p = 1 To 21
- Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
- With xmlhttp
- .Open "get", "http://www.shdjt.com/sort.asp?sortname=&cxrq=" & d & "&sort=&page=" & p, False
- .send
- tmp() = Split(Split(Split(Replace(StrConv(.responsebody, vbUnicode, &H804), "><a class=", "a class="), "</thead>")(1), "<span id=""bar""")(0), "<td")
- End With
- ReDim arr(UBound(tmp) \ 38, 37)
- For i = 1 To UBound(tmp)
- arr((i - 1) \ 38, (i - 1) Mod 38) = Split(Split(tmp(i), ">")(1), "</")(0)
- Next
-
- n = sh.[a65536].End(xlUp).Row + 1
- sh.Cells(n, 1).Resize(UBound(arr) + 1, 38) = arr
- Erase tmp
- Erase arr
- Set xmlhttp = Nothing
-
- Next
-
- sh.[a:AL].Columns.AutoFit
-
- MsgBox "Ok"
- End Sub
复制代码 |
|