在吹版代码的基础上做了改进,适应不定长数据的提取。大家可以测试下(时间比吹版的时间稍长些)
API代码部分来源于大师(行者孙)及本论坛的大师吹水佬。
程序代码:
DECLARE LONG StrDup IN shlwapi STRING @lpsz
DECLARE LONG LocalFree IN kernel32 LONG
DECLARE LONG strstr IN msvcrt LONG,STRING @
CREATE CURSOR dlt (开奖日期 C(10), 红1 C(2), 红2 C(2), 红3 C(2),红4 C(2),红5 C(2),兰1 C(2),兰2 C(2),期号 C(5),球具 N(1))
cUrl = "https://webapi./gateway/lottery/getHistoryPageListV1.qry?gameNo=85&provinceId=0&pageSize=0&" + SUBSTR(SYS(2015), 2)
oHTTP=NEWOBJECT("MSXML2.XMLHTTP")
oHTTP.Open("GET", cUrl, .F.)
oHTTP.Send()
lcText = oHTTP.ResponseText
t1 = SECONDS()
hMem = StrDup(@lcText)
sys(2600, hMem, len(lcText))
nSize = 100 && 根据JSON块数据的长度做适当调整
p0 = strstr(hMem, "lotteryDrawNum")
DO WHILE p0 > 0
DrawNum = STREXTRACT(SYS(2600, p0, nSize), ':', ',"')
p1 = strstr(p0, "lotteryDrawResult")
p2 = strstr(p1, "lotteryDrawTime")
p0 = strstr(p2, "lotteryEquipmentCount")
lcqh = DrawNum
lckjrq = STREXTRACT(SYS(2600, p2, nSize), ':', ',"')
lcjh = STREXTRACT(SYS(2600, p1, nSize), ':', ',"')
lcqj = STREXTRACT(SYS(2600, p0, nSize), ':', ',"')
INSERT INTO dlt VALUES (&lckjrq, SUBSTR(lcjh, 2, 2), SUBSTR(lcjh, 5, 2), SUBSTR(lcjh, 8, 2), SUBSTR(lcjh, 11, 2), SUBSTR(lcjh, 14, 2), SUBSTR(lcjh, 17, 2), SUBSTR(lcjh, 20, 2), &DrawNum, &lcqj)
p0 = strstr(p0, "lotteryDrawNum")
ENDDO
LocalFree(hMem)
CLEAR DLLS
? SECONDS() - t1 && 0.2秒内
BROWSE
[此贴子已经被作者于2021-6-4 17:20编辑过]