以Windows平台为例 这里有一篇对比IECaptCutyCapt在windows平台上的抓取效率的评测:截图软件IECapt与CutyCapt Win平台对比

我要实现的是目的是:在windows机器上,用iecapt自动抓取aaa/bbb/ccc三个网站的首页,文件分别存放,以日期-时间格式命名

那么,编写一个批处理文件snap.bat,将这个文件和iecapt.exe一起放入某个目录,本例是e:\web\snap,然后加入计划任务即可,当然,用作计划任务的话,那些echo语句可以去掉

@echo off
set dst=%date:~0,4%%date:~5,2%%date:~8,2%
set tst=%time:~0,2%%time:~3,2%%time:~6,2%
if "%time:~0,1%"==" " set tst=0%time:~1,1%%time:~3,2%%time:~6,2%
set file=%dst%%tst%.png
 
set dir=e:\web\snap\
set url1=www.baidu.com
set url2=www.youdao.com
set url3=www.sogou.com
 
set file1=%dir%%url1%\%file%
set file2=%dir%%url2%\%file%
set file3=%dir%%url3%\%file%
 
if not exist %dir%%url1% md %dir%%url1%
if not exist %dir%%url2% md %dir%%url2%
if not exist %dir%%url3% md %dir%%url3%
 
echo Now Capture %url1% ...
%dir%iecapt.exe --url=http://%url1% --out=%file1% --delay=2000
echo.
 
echo Now Capture %url2% ...
%dir%iecapt.exe --url=http://%url2% --out=%file2% --delay=2000
echo.
 
echo Now Capture %url3% ...
%dir%iecapt.exe --url=http://%url3% --out=%file3% --delay=2000
echo.
echo.
echo.
echo ============ Fetch Result =======================
echo.
if EXIST %file1% (echo Succesess! Fetched %url1%) else (echo Failed fetch %url1%)
echo.
if EXIST %file2% (echo Succesess! Fetched %url2%) else (echo Failed fetch %url2%)
echo.
if EXIST %file3% (echo Succesess! Fetched %url3%) else (echo Failed fetch %url3%)
echo.
echo ============ Fetch Result =======================
echo.

文中第四行:是判断如果当前时间的“时”是个位数的话,前面自动加0,这一步很重要

张宴的另外一种写法,貌似更简单一些

@echo off
set time_hh=%time:~0,2%
if /i %time_hh% LSS 10 (set time_hh=0%time:~1,1%)
set filename=%date:~,4%%date:~5,2%%date:~8,2%_%time_hh%%time:~3,2%%time:~6,2%
echo %filename%

IECapt的使用方法:

-----------------------------------------------------------------------------

 Usage: IECapt --url=http://www.example.org/ --out=localfile.png

 -----------------------------------------------------------------------------

  --help                      Print this help page and exit

  --url=<url>                 The URL to capture (http:...|file:...|...)

  --out=<path>                The target file (.png|bmp|jpeg|emf|...)

  --min-width=<int>           Minimal width for the image (default: 800)

  --max-wait=<ms>             Don't wait more than (default: 90000, inf: 0)

  --delay=<ms>                Wait after loading (e.g. for Flash; default: 0)

  --silent                    Whether to surpress some dialogs

 -----------------------------------------------------------------------------