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