给大家送点福利

独自等待 2017年5月10日16:14:54评论588 views字数 2103阅读7分0秒阅读模式

最近比较忙,忙完等保忙培训,没个尽头呀,不过好在能从中学习到比较多的知识。

前段时间安装了windows10 激活以后用了一段时间,然后老是重新提示要激活,激活状态明显是已经激活的,不知道怎么回事,对于强迫症的我来说,很烦,于是重装了win7。之前用的壁纸也不爽了,网上找了好久,终于找到个不错的壁纸站,彼岸壁纸,网址如下:http://www.netbian.com/ 折腾了个python脚本,下载了N多美女壁纸,送给大家当福利了,喜欢的拿走。

彼岸壁纸

下载器,默认只下载10页的,大概180张图片,可自行修改。

彼岸壁纸下载器:

#!/usr/bin/env python
# -*- coding: gbk -*-
# -*- coding: utf-8 -*-
# Date: 2016/4/25
# Created by 独自等待
# 博客 http://www.waitalone.cn/
import urllib2

try:
    from lxml import html
except ImportError:
    raise SystemExit(u'模块导入错误,请使用pip install lxml安装!')

nums = 10  # 下载多少页,每页大概18张
imgtype = 'meinv'  # 壁纸的分类,比如:meinv,fengjing


def downlist():
    u"获取需要下载的壁纸列表函数"
    todownlist = []  # 保存需要下载的壁纸URL

    for i in range(1, nums + 1):
        if i == 1:
            url = 'http://www.netbian.com/' + imgtype + '/index.htm'
        else:
            url = 'http://www.netbian.com/' + imgtype + '/index_%d.htm' % i
        try:
            response = urllib2.urlopen(url, timeout=10).read()
        except Exception, msg:
            print msg
        else:
            imglink = html.fromstring(response)
            imgalist = imglink.xpath('//div[@class="list"]/ul/li/a/@href')
            imgalist = [l.replace('.htm', '') for l in imgalist if 'desk' in l]
            downlist = ['http://www.netbian.com' + d + '-1920x1080.htm' for d in imgalist]
            todownlist.extend(downlist)
    return todownlist


def downimg():
    u"下载壁纸并自动更名"
    cnt = 0
    for link in downlist():
        cnt += 1
        try:
            response = urllib2.urlopen(link, timeout=10).read()
        except Exception, msg:
            print msg
        else:
            img = html.fromstring(response)
            imgsrclist = img.xpath('//td[@align="left"]/img/@src')
            try:
                if imgsrclist:
                    imgres = urllib2.urlopen(imgsrclist[0]).read()
                else:
                    continue
            except Exception, msg:
                print msg
            else:
                print u'[!] 爷,小的正努力下载[ %s ]类第[ %.3d ]张壁纸!' % (imgtype, cnt)
                with open(imgtype + u'壁纸%.3d.jpg' % cnt, 'wb') as imgfile:
                    imgfile.write(imgres)


if __name__ == '__main__':
    print '+' + '-' * 60 + '+'
    print u'\t\tPython 彼岸壁纸下载器'
    print u'\t   Blog:http://www.waitalone.cn/'
    print u'\t\t Code BY: 独自等待'
    print u'\t\t Time:2016-04-25'
    print '+' + '-' * 60 + '+'
    print u'正在下载中,请稍候……\n'
    try:
        downimg()
    except KeyboardInterrupt:
        print u'[x] 爷,还没有下载完哦!'
    print u'\n恭喜爷,已经下载完毕.请查看!'

 

请大家重新保存,修复几处错误。。保存后请尽快使用,以免失效呢。



from www.waitalone.cn.thanks for it.

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
独自等待
  • 本文由 发表于 2017年5月10日16:14:54
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   给大家送点福利https://cn-sec.com/archives/50011.html

发表评论

匿名网友 填写信息