|
DDX把股票名称的修正好了,代码如下,excel如附件
- Sub Test()
- Dim i As Long, rw As Long
- Dim tmp() As String, arr() As String
- Dim p As Long
-
- [a1:t1] = Split("股票代码,股票名称,最新价,涨跌幅,换手率,量比,DDX,DDY,DDZ,DDX60,DDY60,5日内,10日内,连续,连增,涨速5,特大买,特大卖,小单买,小单卖", ",")
- On Error Resume Next
- For p = 1 To 41
- rw = [a65536].End(xlUp).Row + 1
-
- With CreateObject("Microsoft.XMLHTTP")
- .Open "get", "http://www.ddx.name/script/DDEscript.asp?mk=&sortID=7&sortBY=-1&page=" & p & "&randNum=0.7210666082133784", False
- .setRequestHeader "Content-Type", "text/html"
- .send
- tmp() = Split(Split(Split(Replace(Replace(.responsetext, """", ""), "],[", ","), "var pageArray = new Array([")(1), "]);")(0), ",")
- End With
- ReDim arr(UBound(tmp) \ 20, 19)
- For i = 0 To UBound(tmp)
- arr(i \ 20, i Mod 20) = tmp(i)
- Next
- Cells(rw, 1).Resize(UBound(arr) + 1, 20) = arr
- Next
- [a:t].Columns.AutoFit
-
- Dim nm As Long
- Dim j As Long, k As Long
- Dim gp() As String, tmp1() As String
- Dim m As Long
-
- With CreateObject("Microsoft.XMLHTTP")
- .Open "get", "http://www.ddx.name/js/stockCode.js", False
- .setRequestHeader "Content-Type", "text/html"
- .send
- tmp1() = Split(Split(Split(Replace(Replace(StrConv(.responsebody, vbUnicode, &H804), """", ""), "],[", ","), "var stockCodeArray=new Array([")(1), "]);")(0), ",")
- End With
- ReDim gp(UBound(tmp1) \ 2, 1)
- For m = 0 To UBound(tmp1)
- gp(m \ 2, m Mod 2) = tmp1(m)
- Next
-
- nm = [a65536].End(xlUp).Row - 1
- For j = 1 To nm
- For k = 1 To UBound(gp) + 1
- If Trim(Cells(j + 1, 1).Value) = gp(k - 1, 0) Then Cells(j + 1, 2).Value = gp(k - 1, 1): Exit For
- Next
- Next
-
- MsgBox "Ok"
- End Sub
复制代码 |
|