我想运行一个iMacro来保存大量网页(论坛上的线程)。我在VBA中解决了这个问题,但无法让它运行iMacro。
我现在尝试过javascript。我想将一些基本参数(线程编号,起始页码,要保存的页数,文件类型)传递给iMacro,然后循环直到所有页面都保存完毕。这就是我到目前为止所提出的。
<script type="text/javascript">
<!--
var THRNO = prompt("Enter thread number”);
var PGST = prompt("Enter page start number”);
var PGNO = prompt("Enter number of pages to save”);
var THRNM = prompt("Enter thread name/identifier for files”);
var FLTP = prompt("Enter save file type”);
var CNTR = 1
do {
var URLN = "http://www.mysite.co.uk/my-forum/showthread.php?t=" & THRNO & "&page=" & CNTR
var FLNM = THRNM & ".html"
iimSet("URLN", URLN)
iimSet("FLTP", FLTP)
iimSet("FLNM", FLNM)
iimPlay("iMacroUniversal.iim")
CNTR = CNTR + 1
} while (CNTR < PGNO);
//-->
</script>
我的iMacro的代码是
URL GOTO=URLN
SAVEAS TYPE=FLTP FOLDER=D:\MyFolder FILE=FLNM
WAIT SECONDS=2
当我在Excel中将其作为VBA代码编写时,它将采用所有参数并打开iMacros界面但不运行iMacro本身(没有错误消息 - 没有发生任何事情)。我知道我可能正在混淆和修改我的编码语言。
答案 0 :(得分:1)
var macro;
macro ="CODE:";
macro +="URL GOTO={{URLN}}"+"\n";
macro +="SAVEAS TYPE={{FLTP}} FOLDER=D:\MyFolder FILE={{FLNM}}"+"\n";
macro +="WAIT SECONDS=2"+"\n";
var THRNO = prompt("Enter thread number”);
var PGST = prompt("Enter page start number”);
var PGNO = prompt("Enter number of pages to save”);
var THRNM = prompt("Enter thread name/identifier for files”);
var FLTP = prompt("Enter save file type”);
var CNTR = 1
do {
var URLN = "http://www.mysite.co.uk/my-forum/showthread.php?t=" + THRNO + "&page=" + CNTR;
var FLNM = THRNM + ".html"
iimSet("URLN", URLN)
iimSet("FLTP", FLTP)
iimSet("FLNM", FLNM)
iimPlay(macro)
CNTR = CNTR + 1;
} while (CNTR < PGNO);
//-->
将它放在.js文件中,看看它是否有效。