Amazonに自動ログインして、タイムセールを表示するVBScript

· 1 min read
Amazonに自動ログインして、タイムセールを表示するVBScript


InternetExplorerを利用して、Amazonにログイン後にタイムセールを表示するだけのスクリプト。
今回はかなり短めの単発記事です。

スクリプト内容

Dim wsh
Set wsh = WScript.CreateObject("WScript.Shell")

Dim ie 
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
'ie.FullScreen = True

Dim wLoc, wSvc, wEnu, wIns
Set wLoc = CreateObject("WbemScripting.SWbemLocator")
Set wSvc = wLoc.ConnectServer
Set wEnu = wSvc.InstancesOf("Win32_Process")
Dim pId
For Each wIns in wEnu
    If Not IsEmpty(wIns.ProcessId) And wIns.Description = "iexplore.exe" Then
        pId = wIns.ProcessId
    End If
Next
Set wLoc = Nothing
Set wEnu = Nothing
Set wSvc = Nothing
While not wsh.AppActivate(pId) 
    Wscript.Sleep 100 
Wend 

ie.Navigate "https://www.amazon.co.jp/ap/signin?openid.pape.max_auth_age=900&openid.return_to=https%3A%2F%2Fwww.amazon.co.jp%2Fap%2Fcnep%3Fie%3DUTF8%26orig_return_to%3Dhttps%253A%252F%252Fwww.amazon.co.jp%252Fyour-account%26openid.assoc_handle%3Djpflex%26pageId%3Djpflex&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.assoc_handle=jpflex&openid.mode=checkid_setup&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fpape%2F1.0&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0"
Do While ie.Busy = True Or ie.readyState <> 4
Loop

Dim elm 
Set elm = ie.document.getElementById("ap_email")
elm.Value = "メールアドレス"

WScript.Sleep 100

Dim elm2 
Set elm2 = ie.document.getElementById("ap_password")
elm2.Value = "パスワード"

WScript.Sleep 100
ie.document.getElementById("signInSubmit").Click

WScript.Sleep 1000

ie.Navigate "https://www.amazon.co.jp/gp/goldbox/ref=nav_cs_gb"
Do While ie.Busy = True Or ie.readyState <> 4
Loop

Set elm = Nothing
Set elm2 = Nothing
Set ie = Nothing
Set wsh = Nothing

使いどころがあるかはかなり微妙ですが…。