2017-09-02 13 views
0

このスクリプトを自動的に実行する必要がありますが、urllist.txtファイルで指定された異なるURLを使用してください。複数のURLを使ったvbsスクリプトの繰り返し

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 ...

あなたが助けてくださいことはできますか?

+0

ファイルシステムオブジェクトを使用してラインで、テキストファイルの行を読んでください。各行について、貼り付けたコードを実行します。 – Gurman

+0

ありがとうございます。 urllist.txtからurlを読むことができます。 スクリプトをこれらのURLに移動してスクリプトを実行させるにはどうすればよいですか? 私はVBScriptのの先頭にこれを追加しました: ファイル名= "urllist.txt" がFSOを設定=のCreateObject( "Scripting.FileSystemObjectオブジェクト") セットF = fso.OpenTextFile(ファイル名) は行いf.AtEndOfStream までWScript.Echo f.ReadLine ループ f.Close –

+0

ちょうど答えに掲載されています。 URLファイルのパスを変数に格納してコードを実行するだけです。 – Gurman

答えて

0

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 
+0

いくつかのURLが完璧に実行されますが、しばらくすると停止します。 IEを閉じると、800A01CEエラーコードにVBScriptランタイムエラーメッセージが表示されます。 睡眠時間をどこかに設定する必要はありますか? –

+0

あなたの質問を編集して、テキストファイルのURLをここで共有できますか?私の側で実行しようとします。 – Gurman

+0

私はFacebookのグループで各グループの警告を設定するためのボタンを押しています。 facebookは、次のアクションを可能にするためにある程度の時間が必要だと思われます。私は睡眠を20000に上げました。今度は再び働きます。 –

関連する問題