基金監(jiān)控助手VBA版是一款在excel上運(yùn)行的基金監(jiān)控軟件,軟件用到了msxml2.xmlhttp和vbscript.regexp這兩庫,功能很簡單,就是看一些基礎(chǔ)的資料,有需要的小伙伴歡迎來西西下載體驗(yàn)。
作者簡介:
之前回復(fù)壇友股票監(jiān)控的帖子只是一時(shí)興起,沒想到后來有位小伙伴私信我,問能不能搞一個(gè)基金監(jiān)控的
中午看了下接口和數(shù)據(jù)就趁著午休(我才不是一個(gè)上班劃水的小機(jī)靈鬼)大概搞了下,主要就用到了msxml2.xmlhttp和vbscript.regexp這倆庫(姑且讓我這么稱呼他倆吧)
功能很簡單,就是看一些基礎(chǔ)的資料,再次要特別感謝接口無償提供者@小熊同學(xué),為數(shù)據(jù)預(yù)處理省了很多功夫,好啦,廢話不多說,下面看代碼吧!
哦,不對(duì),還要上個(gè)演示圖才對(duì)。
源碼分享:
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 "又賺了一個(gè)億呀,僅耗時(shí):" & Format(Timer - t, "0.00秒"), 64, "WatchMen溫馨提示:"
End Sub