基金监控助手VBA版是一款在excel上运行的基金监控软件,软件用到了msxml2.xmlhttp和vbscript.regexp这两库,功能很简单,就是看一些基础的资料,有需要的小伙伴欢迎来好软下载体验。
之前回复坛友股票监控的帖子只是一时兴起,没想到后来有位小伙伴私信我,问能不能搞一个基金监控的
中午看了下接口和数据就趁着午休(我才不是一个上班划水的小机灵鬼)大概搞了下,主要就用到了msxml2.xmlhttp和vbscript.regexp这俩库(姑且让我这么称呼他俩吧)
功能很简单,就是看一些基础的资料,再次要特别感谢接口无偿提供者@小熊同学,为数据预处理省了很多功夫,好啦,废话不多说,下面看代码吧!
哦,不对,还要上个演示图才对。
Option Explicit
Sub Fund()
Dim i%, j%, url$, res$, m, t
Dim arr, mat
t = Timer
Application.ScreenUpdating = False
'==================================================================
With Sheet3
arr = .Range("a5:u" & .[a65536].End(3).Row())
For i = 1 To UBound(arr)
url = "https://api.doctorxiong.club//v1/fund?code=" & arr(i, 1)
arr(i, 1) = "'" & arr(i, 1)
With CreateObject("msxml2.xmlhttp")
.Open "GET", url, False
.send
res = .responseText
End With
With CreateObject("vbscript.regexp")
.Global = True
.Pattern = ":" & Chr(34) & "(.+?)" & Chr(34) & "|:(d.+?),"
Set mat = .Execute(res)
End With: j = 1
For Each m In mat
If j = 2 Then
If m.SubMatches(0) <> "操作成功" Then
MsgBox "接口限制,过几分钟再来查一下吧!", 64, "WatchMen温馨提示"
Exit Sub
End If
ElseIf j > 3 Then
arr(i, j - 2) = IIf(m.SubMatches(0) = "", m.SubMatches(1), m.SubMatches(0))
End If: j = j + 1
Next
Next
.Range("a5").Resize(UBound(arr), UBound(arr, 2)) = arr
End With
Application.ScreenUpdating = True
MsgBox "又赚了一个亿呀,仅耗时:" & Format(Timer - t, "0.00秒"), 64, "WatchMen温馨提示:"
End Sub
显示全部