以该页面为例(必须登录):https://www.instagram.com/p/B4xM7U3Iu-j/
我正在尝试让我的脚本发表评论:
Set IE = WScript.CreateObject("internetexplorer.application")
Set objFSO = CreateObject("Scripting.FileSystemObject")
'============================================================
'Navigate to URL
IE.Visible = true
IE.Navigate "https://www.instagram.com/p/B4xM7U3Iu-j/"
Do While IE.Busy or IE.ReadyState <> 4: WScript.sleep 1000: Loop
Do Until IE.Document.ReadyState = "complete": WScript.sleep 1000: Loop
wscript.sleep 3000
for each textarea in ie.document.getelementsbytagname("textarea")
textarea.click
textarea.innertext = "Test Comment"
next
wscript.sleep 1000
for each button in ie.document.getelementsbytagname("button")
if button.innertext = "Post" then
button.click
Do While IE.Busy or IE.ReadyState <> 4: WScript.sleep 1000: Loop
Do Until IE.Document.ReadyState = "complete": WScript.sleep 1000: Loop
end if
next
wscript.echo "Done"
它会填充文本框中,但不会激活“发布”选项,这意味着它无法识别出它确实存在。这似乎很容易,但是我的努力都没有奏效。同样,必须使用VBScript在IE11中完成。
IE11使用flex,因此您可能需要一个脚本来登录。我做到了(替换“ LOGIN NAME HERE”和“ PASS HERE”):
Set IE = WScript.CreateObject("internetexplorer.application","IE_")
Set objFSO = CreateObject("Scripting.FileSystemObject")
'============================================================
'Navigate to URL
IE.Visible = true
IE.Navigate "https://www.instagram.com/accounts/login/"
Do While IE.Busy or IE.ReadyState <> 4: WScript.sleep 1000: Loop
Do Until IE.Document.ReadyState = "complete": WScript.sleep 1000: Loop
'============================================================
'Log in to Insta
isloggedin = "false"
for each a in ie.document.getelementsbytagname("a")
if instr(a.href,"LOGIN NAME HERE") then
isloggedin = "true"
exit for
end if
next
if isloggedin = "false" then
for each input in ie.document.getelementsbytagname("input")
if input.name = "username" then
input.innertext = "LOGIN NAME HERE"
end if
next
wscript.sleep 2000
for each input in ie.document.getelementsbytagname("input")
if input.name = "password" then
input.innertext = "PASS HERE"
end if
next
wscript.sleep 2000
for each button in ie.document.getelementsbytagname("button")
if button.innertext = "Log In" then
button.click
end if
next
Do While IE.Busy or IE.ReadyState <> 4: WScript.sleep 1000: Loop
Do Until IE.Document.ReadyState = "complete": WScript.sleep 1000: Loop
wscript.sleep 2000
end if
谢谢!