2013-03-03 109 views
0

這個腳本是通過Youtube視頻收集它們的URL意味着循環。iMacros的提取網址

Option Explicit 

'initiate iMacros instance 
Dim iim1, iret 
set iim1 = CreateObject ("imacros") 
iret = iim1.iimInit() 

'navigate to youtube frontpage 
Dim macro 
macro = "CODE:" 
macro = macro + "VERSION BUILD=7601105  " + vbNewLine 
macro = macro + "TAB T=1  " + vbNewLine 
macro = macro + "TAB CLOSEALLOTHERS  " + vbNewLine 
macro = macro + "URL GOTO=http://www.youtube.com/  " + vbNewLine 

iret = iim1.iimPlay(macro) 

'loop through videos 
Dim counter 
counter = 0 
do while not iret < 0 
    counter = counter + 1 
    macro = "CODE:" 
    macro = macro + "TAG POS=R"+Cstr(counter)+" TYPE=IMG ATTR=CLASS:vimg120&&TITLE:*&&HREF:*&&NAME:*&&ALT:video&&SRC:* " + vbNewLine 
    macro = macro + "PROMPT Current<SP>URL:<SP>{{!URLCURRENT}}" + vbNewLine 
    macro = macro + "BACK" 
    iret = iim1.iimPlay(macro) 
loop 


'end 
msgbox "End. We'll close the iMacros browser and exit the VBS script." 

'close iMacros instance 
iret = iim1.iimExit() 

' exit script 
Wscript.Quit(

由於某種原因它似乎沒有工作。 它返回:語法錯誤:未知命令:OPTION,線:1(錯誤代碼:-910) 請幫助我。 謝謝。

編輯:看起來像我想通了這個腳本必須運行一個VBS腳本(File.vbs爲例),而不是iMacros的瀏覽器中直接。

但我仍然有一個問題。 這個腳本是爲了保存在上面的腳本中提取的網址:

SET !EXTRACT {{!URLCURRENT}} 
SAVEAS TYPE=EXTRACT FOLDER=myFolder FILE=myFile.csv 

我到什麼地方插入這到底是什麼?

回答

0

嘗試了這一點,讓我知道,如果它的工作原理。我到目前爲止還沒有做過VBS,但這可以奏效。

Option Explicit 

'initiate iMacros instance 
Dim iim1, iret 
set iim1 = CreateObject ("imacros") 
iret = iim1.iimInit() 

'navigate to youtube frontpage 
Dim macro 
macro = "CODE:" 
macro = macro + "VERSION BUILD=7601105  " + vbNewLine 
macro = macro + "TAB T=1  " + vbNewLine 
macro = macro + "TAB CLOSEALLOTHERS  " + vbNewLine 
macro = macro + "URL GOTO=http://www.youtube.com/  " + vbNewLine 

iret = iim1.iimPlay(macro) 

'loop through videos 
Dim counter 
counter = 0 
do while not iret < 0 
    counter = counter + 1 
    macro = "CODE:" 
    macro = macro + "TAG POS=R"+Cstr(counter)+" TYPE=IMG ATTR=CLASS:vimg120&&TITLE:*&&HREF:*&&NAME:*&&ALT:video&&SRC:* " + vbNewLine 
    macro = macro + "PROMPT Current<SP>URL:<SP>{{!URLCURRENT}}" + vbNewLine 
macro = macro + "SET !EXTRACT {{!URLCURRENT}}" + vbNewLine 
macro = macro + "SAVEAS TYPE=EXTRACT FOLDER=myFolder FILE=myFile.csv" + vbNewLine 
    macro = macro + "BACK" 
    iret = iim1.iimPlay(macro) 
loop 


'end 
msgbox "End. We'll close the iMacros browser and exit the VBS script." 

'close iMacros instance 
iret = iim1.iimExit() 

' exit script 
Wscript.Quit() 
+0

嘿IceD, 感謝您的回覆。 它返回此錯誤:ActiveX組件不能創建對象:'imacros' 行:5 char:1 我使用Imacros的火狐不是完整的Imacros版本,如果有幫助。 – user2120497 2013-03-05 07:37:26

+0

我donn't知道如何幫助你在這一個,因爲我不這樣做,但VB這可以幫助你。 http://wiki.imacros.net/Main_Page – macroscripts 2013-03-05 23:29:38