Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4450740
  • 博文数量: 1214
  • 博客积分: 13195
  • 博客等级: 上将
  • 技术积分: 9105
  • 用 户 组: 普通用户
  • 注册时间: 2007-01-19 14:41
个人简介

C++,python,热爱算法和机器学习

文章分类

全部博文(1214)

文章存档

2021年(13)

2020年(49)

2019年(14)

2018年(27)

2017年(69)

2016年(100)

2015年(106)

2014年(240)

2013年(5)

2012年(193)

2011年(155)

2010年(93)

2009年(62)

2008年(51)

2007年(37)

分类: Python/Ruby

2011-06-06 22:09:20

下载google历史 official logos的shell脚本。注:由于GFW的原因,一些图片可能无法下载。
Bash语言:
#!/bin/bash

# 下载google official logos的脚本
# 各个网站的
# 被否决的
#
# another web for google logo http://google.zdevo.com/catalog.asp?page=1

html_base=
image_base=
season=(1 2 3 4)
last_century=(98 99)
this_century=(00 01 02 03 04 05 06 07 08 09)
# length: ${#this_century[@]} ${#this_century[*]}
# all id: ${!this_century[@]} ${!this_century[*]}

download_html()
{
    for i in ${last_century[@]}
    do
        for j in ${season[@]}
        do
            wget -ckp ${html_base}logos$i-$j.html
        done
    done

    for i in ${this_century[*]}
    do
        for j in ${season[@]}
        do
            wget -ckp ${html_base}logos$i-$j.html
        done
    done

    for ((i=10; i<=11; ++i))
    do
        for j in ${season[@]}
        do
            wget -ckp ${html_base}logos$i-$j.html
        done
    done
}

#分析html里面链接,获取下载链接,下载图片
download_image()
{
    mkdir bak_logo_html/
    for file in `ls | grep ^logos | grep .html$`
    do
        dir=`echo $file | awk -F'-' '{print $1}' | cut -b 6,7`
        mkdir $dir

        images=$(cat $file | grep \<img\ alt= | grep /logos/ | awk -F'src="' '{print $2}' | awk -F'"' '{print $1}')
        for img in $images
        do
            wget -c $image_base$img
            mv `basename $img` $dir
        done

        mv $file bak_logo_html/
    done
}

download_html

# 后来废弃这个函数,给wget下载网页时加了一个-k转换链接 -p下载图片
#download_image
阅读(1337) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~