Imacros提取网址

时间:2013-03-03 06:21:15

标签: vbscript imacros

此脚本用于循环播放收集其网址的Youtube视频。

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(

由于某些原因它似乎不起作用。 它返回:SyntaxError:unknown命令:OPTION,line:1(错误代码:-910) 请帮帮我。 感谢。

编辑:看起来我发现这个脚本必须作为VBS脚本(例如File.vbs)运行,而不是直接在Imacros浏览器中运行。

但我还是有问题。 此脚本用于保存在上述脚本中提取的URL:

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

我应该在哪里准确插入?

1 个答案:

答案 0 :(得分: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()