免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2781 | 回复: 3
打印 上一主题 下一主题

[网络相关] wget或curl如何下载缩略图背后的大图 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-12-08 09:14 |只看该作者 |倒序浏览
本帖最后由 prints 于 2013-12-08 09:16 编辑

有许多网站给出的一组图片都是以缩略图的方式,如果要看大图就得点开一下,如果想批量下载这样的图怎么办呢?
前提是图片的命名不是正常的步长001..0010这样关系,例如:下面这样的壁纸图片如何批量下载下来。
http://wallcoo.com/nature/Magic_ ... Breitung/index.html

顺带问一下可以匿名访问的网页:wget -O- http://...... | grep -o 'http://abc/.*jpg' 这样的情况在Linux下可以筛选出符合的JPG,在Windows下就不可以,不知道各位有没有这样的情况。

还望多指教!

论坛徽章:
15
2015年辞旧岁徽章
日期:2015-03-03 16:54:15双鱼座
日期:2015-01-15 17:29:44午马
日期:2015-01-06 17:06:51子鼠
日期:2014-11-24 10:11:13寅虎
日期:2014-08-18 07:10:55酉鸡
日期:2014-04-02 12:24:51双子座
日期:2014-04-02 12:19:44天秤座
日期:2014-03-17 11:43:36亥猪
日期:2014-03-13 08:13:51未羊
日期:2014-03-11 12:42:03白羊座
日期:2013-11-20 10:15:18CU大牛徽章
日期:2013-04-17 11:48:45
2 [报告]
发表于 2013-12-08 18:00 |只看该作者
  1. man lynx

  2. lynx -dump http://wallcoo.com/nature/Magic_Landscapes_by_Michael_Breitung/index.html |tee  output
复制代码
如果没有lynx,就自己装一个。

用上面的命令会自动生成一个txt 文件,自己再提取关键字和相应的大图链接,随后用wget去下载大图片。

比如第一步,过滤出下面的链接:
  1. http://wallcoo.com/nature/Magic_Landscapes_by_Michael_Breitung/adraga.html
  2. http://wallcoo.com/nature/Magic_Landscapes_by_Michael_Breitung/alpen-glory.html
  3. http://wallcoo.com/nature/Magic_Landscapes_by_Michael_Breitung/anse-lazio.html
  4. http://wallcoo.com/nature/Magic_Landscapes_by_Michael_Breitung/arbilot.html
  5. http://wallcoo.com/nature/Magic_Landscapes_by_Michael_Breitung/berchtesgaden.html
  6. http://wallcoo.com/nature/Magic_Landscapes_by_Michael_Breitung/braceletbay.html
  7. http://wallcoo.com/nature/Magic_Landscapes_by_Michael_Breitung/breath.html
  8. http://wallcoo.com/nature/Magic_Landscapes_by_Michael_Breitung/buachailleetivemor.html
  9. http://wallcoo.com/nature/Magic_Landscapes_by_Michael_Breitung/caboraso.html
  10. http://wallcoo.com/nature/Magic_Landscapes_by_Michael_Breitung/cascade.html
  11. http://wallcoo.com/nature/Magic_Landscapes_by_Michael_Breitung/convergence.html
  12. http://wallcoo.com/nature/Magic_Landscapes_by_Michael_Breitung/fairy-pools.html
  13. http://wallcoo.com/nature/Magic_Landscapes_by_Michael_Breitung/franconia.html
  14. http://wallcoo.com/nature/Magic_Landscapes_by_Michael_Breitung/gerold.html
  15. http://wallcoo.com/nature/Magic_Landscapes_by_Michael_Breitung/geroldsee.html
  16. http://wallcoo.com/nature/Magic_Landscapes_by_Michael_Breitung/godrevy.html
  17. http://wallcoo.com/nature/Magic_Landscapes_by_Michael_Breitung/gruinard-bay.html
  18. http://wallcoo.com/nature/Magic_Landscapes_by_Michael_Breitung/horseshoe-bend.html
  19. http://wallcoo.com/nature/Magic_Landscapes_by_Michael_Breitung/hovshallar.html
  20. http://wallcoo.com/nature/Magic_Landscapes_by_Michael_Breitung/kaparkona.html
复制代码

论坛徽章:
15
2015年辞旧岁徽章
日期:2015-03-03 16:54:15双鱼座
日期:2015-01-15 17:29:44午马
日期:2015-01-06 17:06:51子鼠
日期:2014-11-24 10:11:13寅虎
日期:2014-08-18 07:10:55酉鸡
日期:2014-04-02 12:24:51双子座
日期:2014-04-02 12:19:44天秤座
日期:2014-03-17 11:43:36亥猪
日期:2014-03-13 08:13:51未羊
日期:2014-03-11 12:42:03白羊座
日期:2013-11-20 10:15:18CU大牛徽章
日期:2013-04-17 11:48:45
3 [报告]
发表于 2013-12-08 18:16 |只看该作者
找到规律:

如果有这样一个链接:
  1. http://wallcoo.com/nature/Magic_Landscapes_by_Michael_Breitung/alpen-glory.html
复制代码
那么其大图链接将会是:
  1. http://wallcoo.com/nature/Magic_Landscapes_by_Michael_Breitung/wallpapers/1280x1024/alpen-glory.jpg
  2. http://wallcoo.com/nature/Magic_Landscapes_by_Michael_Breitung/wallpapers/1600x1200/alpen-glory.jpg
复制代码
用下面的代码自动拼装链接,及下载图片。
  1. while read line
  2. do
  3.   PIC1=${line%/*}
  4.   PIC2="$PIC1/wallpapers/1280x1024/"
  5.   PIC3="$PIC1/wallpapers/1600x1200/"
  6.   POST=${line##*/}
  7.   POST=${POST%%.*}
  8.   PIC1280=${PIC2}${POST}.jpg
  9.   PIC1600=${PIC3}${POST}.jpg
  10.   wget $PIC1280
  11.   wget $PIC1600
  12. done < output
复制代码

论坛徽章:
0
4 [报告]
发表于 2013-12-08 20:14 |只看该作者
回复 3# rdcwayx


    谢谢版主,这也是种方法,虽然麻烦了一些,但还是谢谢了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP