码迷,mamicode.com
首页 > 编程语言 > 详细

VBA 定时5秒实现网页刷新获取排名数据

时间:2017-11-08 14:49:43      阅读:327      评论:0      收藏:0      [点我收藏+]

标签:vba

Sub refresh()

    On Error Resume Next

    t = Now + TimeValue("00:00:05") ‘时间间隔


     Application.OnTime t, "refresh" ‘定时启动程序

 

    r = Sheets(1).Cells(Rows.Count, 1).End(xlUp).Row


    Set HTML = CreateObject("htmlfile")

    Set xmlhttp = CreateObject("microsoft.xmlhttp")


    URL = "https://www.amazon.cn/dp/B076ZFKV9B/ref=cngwdyfloorv2_recs_0?                pf_rd_p=05f2b7d6-37ec-49bf-8fcf-5d2fec23a061&pf_rd_s=desktop-2&pf_rd_t=36701&pf_rd_i=desktop&pf_rd_m=A1AJ19PSB66TGU&pf_rd_r=8VMK4SXX0P4Z60T90N6V&pf_rd_r=8VMK4SXX0P4Z60T90N6V&pf_rd_p=05f2b7d6-37ec-49bf-8fcf-5d2fec23a061"


xmlhttp.Open "GET", URL, False

xmlhttp.send


HTML.body.innerHtml = xmlhttp.responseText


Rank = HTML.getelementbyid("SalesRank").getElementsByTagName("span")(0).innerHtml


Sheets(1).Cells(r + 1, 1) = Now

Sheets(1).Cells(r + 1, 2) = Rank


End Sub


Sub stop_refresh()

        On Error Resume Next

        Application.OnTime t, "refresh", , False ‘停止程序运行

End Sub


VBA 定时5秒实现网页刷新获取排名数据

标签:vba

原文地址:http://13834900127.blog.51cto.com/3664326/1979810

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!