|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub 大市行情()
- Dim i, j, m, arr, brr, reg As Object, mh, str As String, mark$
- brr = Array(3, 4, 1, 2, 5, 6, 7, 8) '调整顺序用
- Sheet3.UsedRange.Offset(2).ClearContents
- ReDim arr(1 To 4880, 1 To 8)
- Set reg = CreateObject("vbscript.regexp")
- reg.Global = True
- reg.Pattern = "{.+?f2.+?([0-9.-]+).+?f3.+?([0-9.-]+).+?f12.+?([0-9]{6}).+?f14"":""(.+?)"",""f66.+?([0-9.-]+).+?f72.+?([0-9.-]+).+?f78.+?([0-9.-]+).+?f84.+?([0-9.-]+)}"
- Set X = CreateObject("MSXML2.XMLHTTP")
- With X
- For k = 1 To 98
- .Open "GET", "https://push2.eastmoney.com/api/qt/clist/get?cb=jQuery112308664461492381323_1660644771097&fid=f62&po=1&pz=50&pn=" & k & "&np=1&fltt=2&invt=2&ut=b2884a393a59ad64002292a3e90d46a5&fs=m%3A0%2Bt%3A6%2Bf%3A!2,m%3A0%2Bt%3A13%2Bf%3A!2,m%3A0%2Bt%3A80%2Bf%3A!2,m%3A1%2Bt%3A2%2Bf%3A!2,m%3A1%2Bt%3A23%2Bf%3A!2&fields=f2,f3,f12,f14,f66,f72,f78,f84", False
- .send
- Do Until .readyState = 4 And .Status = 200
- DoEvents
- Loop
- str = .responsetext
- str = Replace(str, mark, "") '处置响应数据中的换行
- ' Debug.Print str
- If reg.test(str) Then
- Set mh = reg.Execute(str)
- For i = 1 To mh.Count
- m = m + 1
- For j = 0 To UBound(brr)
- arr(m, j + 1) = mh(i - 1).submatches(brr(j) - 1)
- Next j
- Next i
- End If
- Next k
- End With
- Set X = Nothing
- Set reg = Nothing
- Sheet3.Range("A2").Resize(UBound(arr), UBound(arr, 2)) = arr
- Sheet3.Range("A1:H1") = Array("代码", "名称", "现价", "涨跌幅", "超大单", "大单", "中单", "小单")
- End Sub
复制代码 |
|