小编For*_*den的帖子

VBA XML V6.0 如何让它等待页面加载?

我一直在努力寻找答案,但似乎找不到任何有用的东西。

基本上,我从一个网站上拉取,当您在页面上时,该网站会加载更多项目。我希望我的代码在加载完成后提取最终数据,但不确定如何让 XML httprequest 等待它。

编辑:

Sub pullsomesite()
    Dim httpRequest As XMLHTTP
    Dim DataObj As New MSForms.DataObject
    Set httpRequest = New XMLHTTP
    Dim URL As String
    URL = "somesite"
     With httpRequest
        .Open "GET", URL, True
        .setRequestHeader "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"
        .setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
        Application.Wait Now + TimeValue("0:02:00")
        .send
        ' ... after the .send call finishes, you can check the server's response:
    End With
    While Not httpRequest.readyState = 4            '<---------- wait
Wend
 If httpRequest.Status = 200 Then
 Application.Wait …
Run Code Online (Sandbox Code Playgroud)

xml excel vba xmlhttprequest

3
推荐指数
1
解决办法
7669
查看次数

标签 统计

excel ×1

vba ×1

xml ×1

xmlhttprequest ×1