我需要自动运行此脚本,但使用不同的 url,在 urllist.txt 文件中指定。
Dim objWshShell,IE,searchStr
Set objWshShell = Wscript.CreateObject("Wscript.Shell")
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = True
.Navigate "url.com"
Do While .Busy
WScript.Sleep 100
Loop
set objButtons = IE.document.getElementsByTagName("button")
for each objButton in objButtons
strText = objButton.innerhtml
if InStr(strText,"rtes") > 0 then
'msgbox strText
objButton.click
exit for
end if
next
end with
ie.quit
urllist.txt 内容:
url1.com url2.com ...
你能帮忙吗?
打开文本文件,使用readline方法逐行读取它,并为每一行运行您的代码。
代码:
Dim IE,searchStr, objFso, objFile, strFilePath
strFilePath = "store the file's path in this variable" 'store the path here
Set IE = CreateObject("InternetExplorer.Application")
IE.visible=True
Set objFso = createObject("Scripting.FileSystemObject")
Set objFile = objFso.OpenTextFile(strFilePath,1)
While Not objFile.AtEndOfStream
IE.Navigate trim(objFile.Readline)
Do While IE.Busy
WScript.Sleep 100
Loop
set objButtons = IE.document.getElementsByTagName("button")
for each objButton in objButtons
strText = objButton.innerhtml
if InStr(1,strText,"rtes") > 0 then
'msgbox strText
objButton.click
exit for
end if
next
Wend
IE.Quit
objFile.Close
Set objFile = Nothing
Set objFso = Nothing
Set IE = Nothing
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句