2015-09-04 46 views

回答

1

有没有大小选项对于wget的递归下载,但您可以将自己的方式提供给图片网址列表,您可以检查其下载的Content-Length。你可以在bash脚本中做到这一点。

#Retrieve image URLs from site 
image_urls=`wget --spider --force-html -r -l2 "http://www.website.com" 2>&1 | grep '^--' | awk '{ print $3 }' | grep '\.\(jpeg\|jpg\|bmp\|gif\|png\)$'` 
for image_url in $image_urls 
do 
    size=`wget -d -qO- "$image_url" 2>&1 | grep 'Content-Length' | awk {'print $2'}` 
#download only download images less than 100,000 bytes 
    if [[ $size < 100000 ]] ;then 
    wget $image_url 
    fi 
done 
+0

谢谢你,但是当我尝试运行该脚本(在Mac OSX)我得到的消息:一边寻找匹配意外EOF: /用户/姓名/台式机/ ImageScript4:命令替换:3号线'''' /用户/名称/桌面/ ImageScript4:命令替换:第4行:语法错误:意外的文件结尾 – n00bly

+0

看起来我得到它的工作...我可以只改变“if [[$ size <100000] ];然后“如果[[$ size> 100000]]”;“然后”只得到超过100kb的图像? – n00bly

+0

是的,你是对的。 –