以下是引用sdta在2021-9-5 19:53:27的发言:
我的电脑上下载第17页失败,不知是什么原因
我的电脑上下载第17页失败,不知是什么原因
试试增加延时
INKEY(2) && 要延时
[此贴子已经被作者于2021-9-7 17:00编辑过]
CREATE CURSOR 税收政策库 (title M, DOCNOVAL C(160), url C(160)) cUrl = "http://www.chinatax./api/query?siteCode=bm29000fgk&tab=all&key=9A9C42392D397C5CA6C1BF07E2E0AA6F" wh = CREATEOBJECT("WinHttp.WinHttpRequest.5.1") sc = CREATEOBJECT("ScriptControl") sc.Language = "JavaScript" ? "每页100行"+0h0D0A UrlToTable(cUrl) SELECT * FROM 税收政策库 CLEAR ALL RETURN FUNCTION UrlToTable(cUrl) LOCAL nPage,cData,jsCode,i,err nPage = 1 DO WHILE .T. cData = UrlToData(cUrl, nPage) cData = LOWER(cData) && VFP解释时只认小写??? TEXT TO jsCode TEXTMERGE NOSHOW PRETEXT 15 var data=<<cData>> ENDTEXT err = .F. TRY sc.AddCode(jsCode) CATCH err = .T. ENDTRY IF err ? "获取数据失败" EXIT ENDIF IF sc.CodeObject.data.resultList.length == 0 && 没有数据 EXIT ENDIF FOR EACH oList IN sc.CodeObject.data.resultList INSERT INTO 税收政策库 VALUES (oList.title, oList.customHs.DOCNOVAL, oList.url) ENDFOR ?? "第 "+TRANSFORM(nPage)+" 页" + 0h0D nPage = nPage + 1 ENDDO ENDFUNC FUNCTION UrlToData(cUrl, nPage) wh.Open("POST", cUrl, 0) wh.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8") wh.Send("timeOption=0&page="+TRANSFORM(nPage)+"&pageSize=100&keyPlace=1&sort=dateDesc&qt=*") RETURN wh.ResponseText ENDFUNC
[此贴子已经被作者于2021-9-7 17:20编辑过]