最近用uniapp白嫖阿里云数据库搞了个壁纸小程序,但是没有壁纸可以放进去呀。。那就只能捡起我的老本行 - python爬APP的壁纸图片了~~
安装python环境
第一步肯定是安装一个python环境啦。。因为用的是mac,会自带python2.7。。就不多说了,可以自行搜索安装方法的。
其次就是安装IDE啦。推荐:pycharm,如果你想用txt文本写也可以。
开始写代码啦
先格式化代码
#coding=utf-8
这句话必须要写在第一行,不然会将中文解析成乱码
引入需要的包
代码语言:javascript复制import requests
improt time
定义header,便于识别非爬虫请求接口
代码语言:javascript复制header = {
'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36'
}
进入正题了
先定义需要的参数
代码语言:javascript复制 pn = 30 // 接口每页返回的条数,后面需要累加的,每次累加30
page = 100 // 需要爬取的页数
开始循环页数去爬取壁纸图片啦
代码语言:javascript复制for p in range(1, page):
url = 'http://service.picasso.adesk.com/v1/vertical/category/4e4d610cdf714d2966000000/vertical?'
# 最新 order: new
# 热门 order: hot
param = { // 请求时需要的参数
'limit': 30, // 每页固定返回30条
'skip': pn,
'adult': 'false',
'first': 0,
'order': 'hot' // 分类:hot是热门,new是最新
}
#将编码形式转换为utf-8
page_text = requests.get(url=url,headers=header,params=param)
page_text.encoding = 'utf-8'
page_text = page_text.json()
print page_text
打印出来的数据如下:
代码语言:javascript复制/*
* 提示:该行代码过长,系统自动注释不进行高亮。一键复制会移除系统注释
* {u'msg': u'success', u'res': {u'vertical': [{u'preview': u'http://img5.adesk.com/61d69b54e7bce723c6228a33?sign=57874bf4857d4df11ae166410150b115&t=621ce303', u'thumb': u'http://img5.adesk.com/61d69b54e7bce723c6228a33?imageMogr2/thumbnail/!350x540r/gravity/Center/crop/350x540&sign=57874bf4857d4df11ae166410150b115&t=621ce303', u'img': u'http://img5.adesk.com/61d69b54e7bce723c6228a33?imageMogr2/thumbnail/!1080x1920r/gravity/Center/crop/1080x1920&sign=57874bf4857d4df11ae166410150b115&t=621ce303', u'views': 0, u'cid': [u'4e4d610cdf714d2966000000'], u'rule': u'&imageMogr2/thumbnail/!$<Width>x$<Height>r/gravity/Center/crop/$<Width>x$<Height>', u'ncos': 243, u'rank': 134262, u'source_type': u'vertical', u'tag': [], u'url': [], u'wp': u'http://img5.adesk.com/61d69b54e7bce723c6228a33?sign=57874bf4857d4df11ae166410150b115&t=621ce303', u'xr': False, u'cr': False, u'favs': 484, u'atime': 1641823506.0, u'id': u'61d69b54e7bce723c6228a33', u'store': u'qiniu', u'desc': u''}, {u'preview': u'http://img5.adesk.com/61a72e6531f613712beb5bf8?sign=dd7268f26995d2990b6b4bcdf14f5d87&t=621ce303', u'thumb': u'http://img5.adesk.com/61a72e6531f613712beb5bf8?imageMogr2/thumbnail/!350x540r/gravity/Center/crop/350x540&sign=dd7268f26995d2990b6b4bcdf14f5d87&t=621ce303', u'img': u'http://img5.adesk.com/61a72e6531f613712beb5bf8?imageMogr2/thumbnail/!1080x1920r/gravity/Center/crop/1080x1920&sign=dd7268f26995d2990b6b4bcdf14f5d87&t=621ce303', u'views': 0, u'cid': [u'4e4d610cdf714d2966000000'], u'rule': u'&imageMogr2/thumbnail/!$<Width>x$<Height>r/gravity/Center/crop/$<Width>x$<Height>', u'ncos': 208, u'rank': 117657, u'source_type': u'vertical', u'tag': [], u'url': [], u'wp': u'http://img5.adesk.com/61a72e6531f613712beb5bf8?sign=dd7268f26995d2990b6b4bcdf14f5d87&t=621ce303', u'xr': False, u'cr': False, u'favs': 366, u'atime': 1638972306.0, u'id': u'61a72e6531f613712beb5bf8', u'store': u'qiniu', u'desc': u''}, {u'preview': u'http://img5.adesk.com/61c09ab9e7bce755fec076bd?sign=57abd817e423f50752081525a3294e72&t=621ce303', u'thumb': u'http://img5.adesk.com/61c09ab9e7bce755fec076bd?imageMogr2/thumbnail/!350x540r/gravity/Center/crop/350x540&sign=57abd817e423f50752081525a3294e72&t=621ce303', u'img': u'http://img5.adesk.com/61c09ab9e7bce755fec076bd?imageMogr2/thumbnail/!1080x1920r/gravity/Center/crop/1080x1920&sign=57abd817e423f50752081525a3294e72&t=621ce303', u'views': 0, u'cid': [u'4e4d610cdf714d2966000000'], u'rule': u'&imageMogr2/thumbnail/!$<Width>x$<Height>r/gravity/Center/crop/$<Width>x$<Height>', u'ncos': 225, u'rank': 142911, u'source_type': u'vertical', u'tag': [], u'url': [], u'wp': u'http://img5.adesk.com/61c09ab9e7bce755fec076bd?sign=57abd817e423f50752081525a3294e72&t=621ce303', u'xr': False, u'cr': False, u'favs': 530, u'atime': 1640527505.0, u'id': u'61c09ab9e7bce755fec076bd', u'store': u'qiniu', u'desc': u''}, {u'preview': u'http://img5.adesk.com/61bcb78731f6136f8c2d4153?sign=fe2faeeffd857a2b2eecd72cd5341436&t=621ce303', u'thumb': u'http://img5.adesk.com/61bcb78731f6136f8c2d4153?imageMogr2/thumbnail/!350x540r/gravity/Center/crop/350x540&sign=fe2faeeffd857a2b2eecd72cd5341436&t=621ce303', u'img': u'http://img5.adesk.com/61bcb78731f6136f8c2d4153?imageMogr2/thumbnail/!1080x1920r/gravity/Center/crop/1080x1920&sign=fe2faeeffd857a2b2eecd72cd5341436&t=621ce303', u'views': 0, u'cid': [u'4e4d610cdf714d2966000000'], u'rule': u'&imageMogr2/thumbnail/!$<Width>x$<Height>r/gravity/Center/crop/$<Width>x$<Height>', u'ncos': 753, u'rank': 123516, u'source_type': u'vertical', u'tag': [], u'url': [], u'wp': u'http://img5.adesk.com/61bcb78731f6136f8c2d4153?sign=fe2faeeffd857a2b2eecd72cd5341436&t=621ce303', u'xr': False, u'cr': False, u'favs': 337, u'atime': 1640268306.0, u'id': u'61bcb78731f6136f8c2d4153', u'store': u'qiniu', u'desc': u''}, {u'preview': u'http://img5.adesk.com/61a2d3017e978a3b0ad73141?sign=78a32ee8ee218c7b49d5e9f2c8f02344&t=621ce303', u'thumb': u'http://img5.adesk.com/61a2d3017e978a3b0ad73141?imageMogr2/thumbnail/!350x540r/gravity/Center/crop/350x540&sign=78a32ee8ee218c7b49d5e9f2c8f02344&t=621ce303', u'img': u'http://img5.adesk.com/61a2d3017e978a3b0ad73141?imageMogr2/thumbnail/!1080x1920r/gravity/Center/crop/1080x1920&sign=78a32ee8ee218c7b49d5e9f2c8f02344&t=621ce303', u'views': 0, u'cid': [u'4e4d610cdf714d2966000000'], u'rule': u'&imageMogr2/thumbnail/!$<Width>x$<Height>r/gravity/Center/crop/$<Width>x$<Height>', u'ncos': 198, u'rank': 122418, u'source_type': u'vertical', u'tag': [], u'url': [], u'wp': u'http://img5.adesk.com/61a2d3017e978a3b0ad73141?sign=78a32ee8ee218c7b49d5e9f2c8f02344&t=621ce303', u'xr': False, u'cr': False, u'favs': 370, u'atime': 1638626706.0, u'id': u'61a2d3017e978a3b0ad73141', u'store': u'qiniu', u'desc': u''}, {u'preview': u'http://img5.adesk.com/61e01abe7e978a7300fab4b1?sign=26440680cae4d604a3fa97406e983f22&t=621ce303', u'thumb': u'http://img5.adesk.com/61e01abe7e978a7300fab4b1?imageMogr2/thumbnail/!350x540r/gravity/Center/crop/350x540&sign=26440680cae4d604a3fa97406e983f22&t=621ce303', u'img': u'http://img5.adesk.com/61e01abe7e978a7300fab4b1?imageMogr2/thumbnail/!1080x1920r/gravity/Center/crop/1080x1920&sign=26440680cae4d604a3fa97406e983f22&t=621ce303', u'views': 0, u'cid': [u'4e4d610cdf714d2966000000'], u'rule': u'&imageMogr2/thumbnail/!$<Width>x$<Height>r/gravity/Center/crop/$<Width>x$<Height>', u'ncos': 327, u'rank': 93798, u'source_type': u'vertical', u'tag': [], u'url': [], u'wp': u'http://img5.adesk.com/61e01abe7e978a7300fab4b1?sign=26440680cae4d604a3fa97406e983f22&t=621ce303', u'xr': False, u'cr': False, u'favs': 357, u'atime': 1642514706.0, u'id': u'61e01abe7e978a7300fab4b1', u'store': u'qiniu', u'desc': u''}, {u'preview': u'http://img5.adesk.com/61dc6fc431f6132380613757?sign=a0fb02dd980b2be3281c69cc97db8819&t=621ce303', u'thumb': u'http://img5.adesk.com/61dc6fc431f6132380613757?imageMogr2/thumbnail/!350x540r/gravity/Center/crop/350x540&sign=a0fb02dd980b2be3281c69cc97db8819&t=621ce303', u'img': u'http://img5.adesk.com/61dc6fc431f6132380613757?imageMogr2/thumbnail/!1080x1920r/gravity/Center/crop/1080x1920&sign=a0fb02dd980b2be3281c69cc97db8819&t=621ce303', u'views': 0, u'cid': [u'4e4d610cdf714d2966000000'], u'rule': u'&imageMogr2/thumbnail/!$<Width>x$<Height>r/gravity/Center/crop/$<Width>x$<Height>', u'ncos': 201, u'rank': 128664, u'source_type': u'vertical', u'tag': [], u'url': [], u'wp': u'http://img5.adesk.com/61dc6fc431f6132380613757?sign=a0fb02dd980b2be3281c69cc97db8819&t=621ce303', u'xr': False, u'cr': False, u'favs': 526, u'atime': 1642169107.0, u'id': u'61dc6fc431f6132380613757', u'store': u'qiniu', u'desc': u''}, {u'preview': u'http://img5.adesk.com/61d0e40a31f6130a7d5dcf24?sign=4311823e812307aae33b0587cf7a00e7&t=621ce303', u'thumb': u'http://img5.adesk.com/61d0e40a31f6130a7d5dcf24?imageMogr2/thumbnail/!350x540r/gravity/Center/crop/350x540&sign=4311823e812307aae33b0587cf7a00e7&t=621ce303', u'img': u'http://img5.adesk.com/61d0e40a31f6130a7d5dcf24?imageMogr2/thumbnail/!1080x1920r/gravity/Center/crop/1080x1920&sign=4311823e812307aae33b0587cf7a00e7&t=621ce303', u'views': 0, u'cid': [u'4e4d610cdf714d2966000000'], u'rule': u'&imageMogr2/thumbnail/!$<Width>x$<Height>r/gravity/Center/crop/$<Width>x$<Height>', u'ncos': 238, u'rank': 102420, u'source_type': u'vertical', u'tag': [], u'url': [], u'wp': u'http://img5.adesk.com/61d0e40a31f6130a7d5dcf24?sign=4311823e812307aae33b0587cf7a00e7&t=621ce303', u'xr': False, u'cr': False, u'favs': 394, u'atime': 1641737106.0, u'id': u'61d0e40a31f6130a7d5dcf24', u'store': u'qiniu', u'desc': u''}, {u'preview': u'http://img5.adesk.com/61a72e6531f613712beb5bf5?sign=3c8612d956a4c22077c52bf3f9c30b22&t=621ce303', u'thumb': u'http://img5.adesk.com/61a72e6531f613712beb5bf5?imageMogr2/thumbnail/!350x540r/gravity/Center/crop/350x540&sign=3c8612d956a4c22077c52bf3f9c30b22&t=621ce303', u'img': u'http://img5.adesk.com/61a72e6531f613712beb5bf5?imageMogr2/thumbnail/!1080x1920r/gravity/Center/crop/1080x1920&sign=3c8612d956a4c22077c52bf3f9c30b22&t=621ce303', u'views': 0, u'cid': [u'4e4d610cdf714d2966000000'], u'rule': u'&imageMogr2/thumbnail/!$<Width>x$<Height>r/gravity/Center/crop/$<Width>x$<Height>', u'ncos': 206, u'rank': 128673, u'source_type': u'vertical', u'tag': [], u'url': [], u'wp': u'http://img5.adesk.com/61a72e6531f613712beb5bf5?sign=3c8612d956a4c22077c52bf3f9c30b22&t=621ce303', u'xr': False, u'cr': False, u'favs': 405, u'atime': 1638972306.0, u'id': u'61a72e6531f613712beb5bf5', u'store': u'qiniu', u'desc': u''}, {u'preview': u'http://img5.adesk.com/61bcb80831f6136e73e47877?sign=a2b1abd3f5d0fd0b9d420bf0a20d9436&t=621ce303', u'thumb': u'http://img5.adesk.com/61bcb80831f6136e73e47877?imageMogr2/thumbnail/!350x540r/gravity/Center/crop/350x540&sign=a2b1abd3f5d0fd0b9d420bf0a20d9436&t=621ce303', u'img': u'http://img5.adesk.com/61bcb80831f6136e73e47877?imageMogr2/thumbnail/!1080x1920r/gravity/Center/crop/1080x1920&sign=a2b1abd3f5d0fd0b9d420bf0a20d9436&t=621ce303', u'views': 0, u'cid': [u'4e4d610cdf714d2966000000'], u'rule': u'&imageMogr2/thumbnail/!$<Width>x$<Height>r/gravity/Center/crop/$<Width>x$<Height>', u'ncos': 229, u'rank': 116082, u'source_type': u'vertical', u'tag': [], u'url': [], u'wp': u'http://img5.adesk.com/61bcb80831f6136e73e47877?sign=a2b1abd3f5d0fd0b9d420bf0a20d9436&t=621ce303', u'xr': False, u'cr': False, u'favs': 507, u'atime': 1640527505.0, u'id': u'61bcb80831f6136e73e47877', u'store': u'qiniu', u'desc': u''}, {u'preview': u'http://img5.adesk.com/61ce6c1fe7bce755043aa879?sign=5cf3b329f9510fa882da0c77e9d63588&t=621ce303', u'thumb': u'http://img5.adesk.com/61ce6c1fe7bce755043aa879?imageMogr2/thumbnail/!350x540r/gravity/Center/crop/350x540&sign=5cf3b329f9510fa882da0c77e9d63588&t=621ce303', u'img': u'http://img5.adesk.com/61ce6c1fe7bce755043aa879?imageMogr2/thumbnail/!1080x1920r/gravity/Center/crop/1080x1920&sign=5cf3b329f9510fa882da0c77e9d63588&t=621ce303', u'views': 0, u'cid': [u'4e4d610cdf714d2966000000'], u'rule': u'&imageMogr2/thumbnail/!$<Width>x$<Height>r/gravity/Center/crop/$<Width>x$<Height>', u'ncos': 229, u'rank': 113220, u'source_type': u'vertical', u'tag': [], u'url': [], u'wp': u'http://img5.adesk.com/61ce6c1fe7bce755043aa879?sign=5cf3b329f9510fa882da0c77e9d63588&t=621ce303', u'xr': False, u'cr': False, u'favs': 474, u'atime': 1641564310.0, u'id': u'61ce6c1fe7bce755043aa879', u'store': u'qiniu', u'desc': u''}, {u'preview': u'http://img5.adesk.com/61e01abe7e978a7300fab4b0?sign=8de51d8e0b2432c0e0d06572494eca47&t=621ce303', u'thumb': u'http://img5.adesk.com/61e01abe7e978a7300fab4b0?imageMogr2/thumbnail/!350x540r/gravity/Center/crop/350x540&sign=8de51d8e0b2432c0e0d06572494eca47&t=621ce303', u'img': u'http://img5.adesk.com/61e01abe7e978a7300fab4b0?imageMogr2/thumbnail/!1080x1920r/gravity/Center/crop/1080x1920&sign=8de51d8e0b2432c0e0d06572494eca47&t=621ce303', u'views': 0, u'cid': [u'4e4d610cdf714d2966000000'], u'rule': u'&imageMogr2/thumbnail/!$<Width>x$<Height>r/gravity/Center/crop/$<Width>x$<Height>', u'ncos': 132, u'rank': 92088, u'source_type': u'vertical', u'tag': [], u'url': [], u'wp': u'http://img5.adesk.com/61e01abe7e978a7300fab4b0?sign=8de51d8e0b2432c0e0d06572494eca47&t=621ce303', u'xr': False, u'cr': False, u'favs': 347, u'atime': 1642514706.0, u'id': u'61e01abe7e978a7300fab4b0', u'store': u'qiniu', u'desc': u''}, {u'preview': u'http://img5.adesk.com/61a894ede7bce71f9553f907?sign=6e1a918959ea6c783914f5cd35dcc9e0&t=621ce303', u'thumb': u'http://img5.adesk.com/61a894ede7bce71f9553f907?imageMogr2/thumbnail/!350x540r/gravity/Center/crop/350x540&sign=6e1a918959ea6c783914f5cd35dcc9e0&t=621ce303', u'img': u'http://img5.adesk.com/61a894ede7bce71f9553f907?imageMogr2/thumbnail/!1080x1920r/gravity/Center/crop/1080x1920&sign=6e1a918959ea6c783914f5cd35dcc9e0&t=621ce303', u'views': 0, u'cid': [u'4e4d610cdf714d2966000000'], u'rule': u'&imageMogr2/thumbnail/!$<Width>x$<Height>r/gravity/Center/crop/$<Width>x$<Height>', u'ncos': 191, u'rank': 104805, u'source_type': u'vertical', u'tag': [u'u7f8eu5973', u'u7effu8272', u'u6e05u65b0', u'u521du590f'], u'url': [], u'wp': u'http://img5.adesk.com/61a894ede7bce71f9553f907?sign=6e1a918959ea6c783914f5cd35dcc9e0&t=621ce303', u'xr': False, u'cr': False, u'favs': 262, u'atime': 1639058705.0, u'id': u'61a894ede7bce71f9553f907', u'store': u'qiniu', u'desc': u''}, {u'preview': u'http://img5.adesk.com/61aeacb47e978a3b0add1a2e?sign=f918b568d0653ad57e6cfebe9f2b4d51&t=621ce303', u'thumb': u'http://img5.adesk.com/61aeacb47e978a3b0add1a2e?imageMogr2/thumbnail/!350x540r/gravity/Center/crop/350x540&sign=f918b568d0653ad57e6cfebe9f2b4d51&t=621ce303', u'img': u'http://img5.adesk.com/61aeacb47e978a3b0add1a2e?imageMogr2/thumbnail/!1080x1920r/gravity/Center/crop/1080x1920&sign=f918b568d0653ad57e6cfebe9f2b4d51&t=621ce303', u'views': 0, u'cid': [u'4e4d610cdf714d2966000000'], u'rule': u'&imageMogr2/thumbnail/!$<Width>x$<Height>r/gravity/Center/crop/$<Width>x$<Height>', u'ncos': 164, u'rank': 130455, u'source_type': u'vertical', u'tag': [], u'url': [], u'wp': u'http://img5.adesk.com/61aeacb47e978a3b0add1a2e?sign=f918b568d0653ad57e6cfebe9f2b4d51&t=621ce303', u'xr': False, u'cr': False, u'favs': 427, u'atime': 1639231506.0, u'id': u'61aeacb47e978a3b0add1a2e', u'store': u'qiniu', u'desc': u''}, {u'preview': u'http://img5.adesk.com/61baaf05e7bce722b9dc2ccc?sign=679cb1b5d02e4d72009759c7131f13da&t=621ce303', u'thumb': u'http://img5.adesk.com/61baaf05e7bce722b9dc2ccc?imageMogr2/thumbnail/!350x540r/gravity/Center/crop/350x540&sign=679cb1b5d02e4d72009759c7131f13da&t=621ce303', u'img': u'http://img5.adesk.com/61baaf05e7bce722b9dc2ccc?imageMogr2/thumbnail/!1080x1920r/gravity/Center/crop/1080x1920&sign=679cb1b5d02e4d72009759c7131f13da&t=621ce303', u'views': 0, u'cid': [u'4e4d610cdf714d2966000000'], u'rule': u'&imageMogr2/thumbnail/!$<Width>x$<Height>r/gravity/Center/crop/$<Width>x$<Height>', u'ncos': 158, u'rank': 82305, u'source_type': u'vertical', u'tag': [], u'url': [], u'wp': u'http://img5.adesk.com/61baaf05e7bce722b9dc2ccc?sign=679cb1b5d02e4d72009759c7131f13da&t=621ce303', u'xr': False, u'cr': False, u'favs': 292, u'atime': 1639654321.0, u'id': u'61baaf05e7bce722b9dc2ccc', u'store': u'qiniu', u'desc': u''}, {u'preview': u'http://img5.adesk.com/61d69b54e7bce723c6228a35?sign=3f8a3bc9dab0f4a8f76f955f0ef49e21&t=621ce303', u'thumb': u'http://img5.adesk.com/61d69b54e7bce723c6228a35?imageMogr2/thumbnail/!350x540r/gravity/Center/crop/350x540&sign=3f8a3bc9dab0f4a8f76f955f0ef49e21&t=621ce303', u'img': u'http://img5.adesk.com/61d69b54e7bce723c6228a35?imageMogr2/thumbnail/!1080x1920r/gravity/Center/crop/1080x1920&sign=3f8a3bc9dab0f4a8f76f955f0ef49e21&t=621ce303', u'views': 0, u'cid': [u'4e4d610cdf714d2966000000'], u'rule': u'&imageMogr2/thumbnail/!$<Width>x$<Height>r/gravity/Center/crop/$<Width>x$<Height>', u'ncos': 224, u'rank': 105786, u'source_type': u'vertical', u'tag': [], u'url': [], u'wp': u'http://img5.adesk.com/61d69b54e7bce723c6228a35?sign=3f8a3bc9dab0f4a8f76f955f0ef49e21&t=621ce303', u'xr': False, u'cr': False, u'favs': 389, u'atime': 1641823506.0, u'id': u'61d69b54e7bce723c6228a35', u'store': u'qiniu', u'desc': u''}, {u'preview': u'http://img5.adesk.com/61b9c7ece7bce72001b54486?sign=d63c1e54b6aed818a0ca699b0855babb&t=621ce303', u'thumb': u'http://img5.adesk.com/61b9c7ece7bce72001b54486?imageMogr2/thumbnail/!350x540r/gravity/Center/crop/350x540&sign=d63c1e54b6aed818a0ca699b0855babb&t=621ce303', u'img': u'http://img5.adesk.com/61b9c7ece7bce72001b54486?imageMogr2/thumbnail/!1080x1920r/gravity/Center/crop/1080x1920&sign=d63c1e54b6aed818a0ca699b0855babb&t=621ce303', u'views': 0, u'cid': [u'4e4d610cdf714d2966000000'], u'rule': u'&imageMogr2/thumbnail/!$<Width>x$<Height>r/gravity/Center/crop/$<Width>x$<Height>', u'ncos': 177, u'rank': 112536, u'source_type': u'vertical', u'tag': [u'u7f8eu5973', u'u6027u611f', u'u6c7du8f66', u'u5fa1u59d0'], u'url': [], u'wp': u'http://img5.adesk.com/61b9c7ece7bce72001b54486?sign=d63c1e54b6aed818a0ca699b0855babb&t=621ce303', u'xr': False, u'cr': False, u'favs': 401, u'atime': 1639654241.0, u'id': u'61b9c7ece7bce72001b54486', u'store': u'qiniu', u'desc': u''}, {u'preview': u'http://img5.adesk.com/61e3db417e978a726d5bb865?sign=d367c71ae718da9f334d3369d7cfb68d&t=621ce303', u'thumb': u'http://img5.adesk.com/61e3db417e978a726d5bb865?imageMogr2/thumbnail/!350x540r/gravity/Center/crop/350x540&sign=d367c71ae718da9f334d3369d7cfb68d&t=621ce303', u'img': u'http://img5.adesk.com/61e3db417e978a726d5bb865?imageMogr2/thumbnail/!1080x1920r/gravity/Center/crop/1080x1920&sign=d367c71ae718da9f334d3369d7cfb68d&t=621ce303', u'views': 0, u'cid': [u'4e4d610cdf714d2966000000'], u'rule': u'&imageMogr2/thumbnail/!$<Width>x$<Height>r/gravity/Center/crop/$<Width>x$<Height>', u'ncos': 137, u'rank': 93672, u'source_type': u'vertical', u'tag': [], u'url': [], u'wp': u'http://img5.adesk.com/61e3db417e978a726d5bb865?sign=d367c71ae718da9f334d3369d7cfb68d&t=621ce303', u'xr': False, u'cr': False, u'favs': 432, u'atime': 1642687503.0, u'id': u'61e3db417e978a726d5bb865', u'store': u'qiniu', u'desc': u''}, {u'preview': u'http://img5.adesk.com/61dcfff87e978a7319389a86?sign=f8a5496745715cddce601ef14b3af37d&t=621ce303', u'thumb': u'http://img5.adesk.com/61dcfff87e978a7319389a86?imageMogr2/thumbnail/!350x540r/gravity/Center/crop/350x540&sign=f8a5496745715cddce601ef14b3af37d&t=621ce303', u'img': u'http://img5.adesk.com/61dcfff87e978a7319389a86?imageMogr2/thumbnail/!1080x1920r/gravity/Center/crop/1080x1920&sign=f8a5496745715cddce601ef14b3af37d&t=621ce303', u'views': 0, u'cid': [u'4e4d610cdf714d2966000000'], u'rule': u'&imageMogr2/thumbnail/!$<Width>x$<Height>r/gravity/Center/crop/$<Width>x$<Height>', u'ncos': 471, u'rank': 75663, u'source_type': u'vertical', u'tag': [], u'url': [], u'wp': u'http://img5.adesk.com/61dcfff87e978a7319389a86?sign=f8a5496745715cddce601ef14b3af37d&t=621ce303', u'xr': False, u'cr': False, u'favs': 266, u'atime': 1642082706.0, u'id': u'61dcfff87e978a7319389a86', u'store': u'qiniu', u'desc': u''}, {u'preview': u'http://img5.adesk.com/61ca7ecf31f61309edab8946?sign=06c9055ec03e3f50a63eabac1deae9bf&t=621ce303', u'thumb': u'http://img5.adesk.com/61ca7ecf31f61309edab8946?imageMogr2/thumbnail/!350x540r/gravity/Center/crop/350x540&sign=06c9055ec03e3f50a63eabac1deae9bf&t=621ce303', u'img': u'http://img5.adesk.com/61ca7ecf31f61309edab8946?imageMogr2/thumbnail/!1080x1920r/gravity/Center/crop/1080x1920&sign=06c9055ec03e3f50a63eabac1deae9bf&t=621ce303', u'views': 0, u'cid': [u'4e4d610cdf714d2966000000'], u'rule': u'&imageMogr2/thumbnail/!$<Width>x$<Height>r/gravity/Center/crop/$<Width>x$<Height>', u'ncos': 198, u'rank': 85329, u'source_type': u'vertical', u'tag': [], u'url': [], u'wp': u'http://img5.adesk.com/61ca7ecf31f61309edab8946?sign=06c9055ec03e3f50a63eabac1deae9bf&t=621ce303', u'xr': False, u'cr': False, u'favs': 338, u'atime': 1641305105.0, u'id': u'61ca7ecf31f61309edab8946', u'store': u'qiniu', u'desc': u''}, {u'preview': u'http://img5.adesk.com/61bcb7a77e978a3aa521d7f8?sign=30bf8e34aabf959dcf5c7a4a76b8dad1&t=621ce303', u'thumb': u'http://img5.adesk.com/61bcb7a77e978a3aa521d7f8?imageMogr2/thumbnail/!350x540r/gravity/Center/crop/350x540&sign=30bf8e34aabf959dcf5c7a4a76b8dad1&t=621ce303', u'img': u'http://img5.adesk.com/61bcb7a77e978a3aa521d7f8?imageMogr2/thumbnail/!1080x1920r/gravity/Center/crop/1080x1920&sign=30bf8e34aabf959dcf5c7a4a76b8dad1&t=621ce303', u'views': 0, u'cid': [u'4e4d610cdf714d2966000000'], u'rule': u'&imageMogr2/thumbnail/!$<Width>x$<Height>r/gravity/Center/crop/$<Width>x$<Height>', u'ncos': 2177, u'rank': 82548, u'source_type': u'vertical', u'tag': [], u'url': [], u'wp': u'http://img5.adesk.com/61bcb7a77e978a3aa521d7f8?sign=30bf8e34aabf959dcf5c7a4a76b8dad1&t=621ce303', u'xr': False, u'cr': False, u'favs': 241, u'atime': 1640181906.0, u'id': u'61bcb7a77e978a3aa521d7f8', u'store': u'qiniu', u'desc': u''}, {u'preview': u'http://img5.adesk.com/61a2d3017e978a3b0ad73144?sign=593ac40e853a7e374cfac0fc6a9b42e4&t=621ce303', u'thumb': u'http://img5.adesk.com/61a2d3017e978a3b0ad73144?imageMogr2/thumbnail/!350x540r/gravity/Center/crop/350x540&sign=593ac40e853a7e374cfac0fc6a9b42e4&t=621ce303', u'img': u'http://img5.adesk.com/61a2d3017e978a3b0ad73144?imageMogr2/thumbnail/!1080x1920r/gravity/Center/crop/1080x1920&sign=593ac40e853a7e374cfac0fc6a9b42e4&t=621ce303', u'views': 0, u'cid': [u'4e4d610cdf714d2966000000'], u'rule': u'&imageMogr2/thumbnail/!$<Width>x$<Height>r/gravity/Center/crop/$<Width>x$<Height>', u'ncos': 168, u'rank': 91368, u'source_type': u'vertical', u'tag': [], u'url': [], u'wp': u'http://img5.adesk.com/61a2d3017e978a3b0ad73144?sign=593ac40e853a7e374cfac0fc6a9b42e4&t=621ce303', u'xr': False, u'cr': False, u'favs': 288, u'atime': 1638626706.0, u'id': u'61a2d3017e978a3b0ad73144', u'store': u'qiniu', u'desc': u''}, {u'preview': u'http://img5.adesk.com/61be7b027e978a3a94cb5ca3?sign=bd6b42f98d3aedceb8e06d1c3a8d94a9&t=621ce303', u'thumb': u'http://img5.adesk.com/61be7b027e978a3a94cb5ca3?imageMogr2/thumbnail/!350x540r/gravity/Center/crop/350x540&sign=bd6b42f98d3aedceb8e06d1c3a8d94a9&t=621ce303', u'img': u'http://img5.adesk.com/61be7b027e978a3a94cb5ca3?imageMogr2/thumbnail/!1080x1920r/gravity/Center/crop/1080x1920&sign=bd6b42f98d3aedceb8e06d1c3a8d94a9&t=621ce303', u'views': 0, u'cid': [u'4e4d610cdf714d2966000000'], u'rule': u'&imageMogr2/thumbnail/!$<Width>x$<Height>r/gravity/Center/crop/$<Width>x$<Height>', u'ncos': 176, u'rank': 80577, u'source_type': u'vertical', u'tag': [], u'url': [], u'wp': u'http://img5.adesk.com/61be7b027e978a3a94cb5ca3?sign=bd6b42f98d3aedceb8e06d1c3a8d94a9&t=621ce303', u'xr': False, u'cr': False, u'favs': 330, u'atime': 1640441105.0, u'id': u'61be7b027e978a3a94cb5ca3', u'store': u'qiniu', u'desc': u''}, {u'preview': u'http://img5.adesk.com/61a72e6531f613712beb5bf7?sign=095e418fda6bc1cab17830339aa7b56f&t=621ce303', u'thumb': u'http://img5.adesk.com/61a72e6531f613712beb5bf7?imageMogr2/thumbnail/!350x540r/gravity/Center/crop/350x540&sign=095e418fda6bc1cab17830339aa7b56f&t=621ce303', u'img': u'http://img5.adesk.com/61a72e6531f613712beb5bf7?imageMogr2/thumbnail/!1080x1920r/gravity/Center/crop/1080x1920&sign=095e418fda6bc1cab17830339aa7b56f&t=621ce303', u'views': 0, u'cid': [u'4e4d610cdf714d2966000000'], u'rule': u'&imageMogr2/thumbnail/!$<Width>x$<Height>r/gravity/Center/crop/$<Width>x$<Height>', u'ncos': 183, u'rank': 92358, u'source_type': u'vertical', u'tag': [], u'url': [], u'wp': u'http://img5.adesk.com/61a72e6531f613712beb5bf7?sign=095e418fda6bc1cab17830339aa7b56f&t=621ce303', u'xr': False, u'cr': False, u'favs': 338, u'atime': 1638972306.0, u'id': u'61a72e6531f613712beb5bf7', u'store': u'qiniu', u'desc': u''}, {u'preview': u'http://img5.adesk.com/61aea58531f6136e092d0cec?sign=346d326a0482023fd2128c1b07a154ff&t=621ce303', u'thumb': u'http://img5.adesk.com/61aea58531f6136e092d0cec?imageMogr2/thumbnail/!350x540r/gravity/Center/crop/350x540&sign=346d326a0482023fd2128c1b07a154ff&t=621ce303', u'img': u'http://img5.adesk.com/61aea58531f6136e092d0cec?imageMogr2/thumbnail/!1080x1920r/gravity/Center/crop/1080x1920&sign=346d326a0482023fd2128c1b07a154ff&t=621ce303', u'views': 0, u'cid': [u'4e4d610cdf714d2966000000'], u'rule': u'&imageMogr2/thumbnail/!$<Width>x$<Height>r/gravity/Center/crop/$<Width>x$<Height>', u'ncos': 160, u'rank': 89352, u'source_type': u'vertical', u'tag': [], u'url': [], u'wp': u'http://img5.adesk.com/61aea58531f6136e092d0cec?sign=346d326a0482023fd2128c1b07a154ff&t=621ce303', u'xr': False, u'cr': False, u'favs': 303, u'atime': 1639231506.0, u'id': u'61aea58531f6136e092d0cec', u'store': u'qiniu', u'desc': u''}, {u'preview': u'http://img5.adesk.com/61e26ab7e7bce723a404a312?sign=c85f08db44328ca86684f5379e6ad861&t=621ce303', u'thumb': u'http://img5.adesk.com/61e26ab7e7bce723a404a312?imageMogr2/thumbnail/!350x540r/gravity/Center/crop/350x540&sign=c85f08db44328ca86684f5379e6ad861&t=621ce303', u'img': u'http://img5.adesk.com/61e26ab7e7bce723a404a312?imageMogr2/thumbnail/!1080x1920r/gravity/Center/crop/1080x1920&sign=c85f08db44328ca86684f5379e6ad861&t=621ce303', u'views': 0, u'cid': [u'4e4d610cdf714d2966000000'], u'rule': u'&imageMogr2/thumbnail/!$<Width>x$<Height>r/gravity/Center/crop/$<Width>x$<Height>', u'ncos': 132, u'rank': 86013, u'source_type': u'vertical', u'tag': [], u'url': [], u'wp': u'http://img5.adesk.com/61e26ab7e7bce723a404a312?sign=c85f08db44328ca86684f5379e6ad861&t=621ce303', u'xr': False, u'cr': False, u'favs': 383, u'atime': 1642601104.0, u'id': u'61e26ab7e7bce723a404a312', u'store': u'qiniu', u'desc': u''}, {u'preview': u'http://img5.adesk.com/61bcb91731f6136e73e47965?sign=ec611a8933656651b18b4329b755ccb7&t=621ce303', u'thumb': u'http://img5.adesk.com/61bcb91731f6136e73e47965?imageMogr2/thumbnail/!350x540r/gravity/Center/crop/350x540&sign=ec611a8933656651b18b4329b755ccb7&t=621ce303', u'img': u'http://img5.adesk.com/61bcb91731f6136e73e47965?imageMogr2/thumbnail/!1080x1920r/gravity/Center/crop/1080x1920&sign=ec611a8933656651b18b4329b755ccb7&t=621ce303', u'views': 0, u'cid': [u'4e4d610cdf714d2966000000'], u'rule': u'&imageMogr2/thumbnail/!$<Width>x$<Height>r/gravity/Center/crop/$<Width>x$<Height>', u'ncos': 166, u'rank': 96921, u'source_type': u'vertical', u'tag': [], u'url': [], u'wp': u'http://img5.adesk.com/61bcb91731f6136e73e47965?sign=ec611a8933656651b18b4329b755ccb7&t=621ce303', u'xr': False, u'cr': False, u'favs': 262, u'atime': 1640527505.0, u'id': u'61bcb91731f6136e73e47965', u'store': u'qiniu', u'desc': u''}, {u'preview': u'http://img5.adesk.com/61d015aee7bce755fec80a8f?sign=eaabc962c1dce865af422f1cf13bede0&t=621ce303', u'thumb': u'http://img5.adesk.com/61d015aee7bce755fec80a8f?imageMogr2/thumbnail/!350x540r/gravity/Center/crop/350x540&sign=eaabc962c1dce865af422f1cf13bede0&t=621ce303', u'img': u'http://img5.adesk.com/61d015aee7bce755fec80a8f?imageMogr2/thumbnail/!1080x1920r/gravity/Center/crop/1080x1920&sign=eaabc962c1dce865af422f1cf13bede0&t=621ce303', u'views': 0, u'cid': [u'4e4d610cdf714d2966000000'], u'rule': u'&imageMogr2/thumbnail/!$<Width>x$<Height>r/gravity/Center/crop/$<Width>x$<Height>', u'ncos': 201, u'rank': 88965, u'source_type': u'vertical', u'tag': [], u'url': [], u'wp': u'http://img5.adesk.com/61d015aee7bce755fec80a8f?sign=eaabc962c1dce865af422f1cf13bede0&t=621ce303', u'xr': False, u'cr': False, u'favs': 334, u'atime': 1641823506.0, u'id': u'61d015aee7bce755fec80a8f', u'store': u'qiniu', u'desc': u''}, {u'preview': u'http://img5.adesk.com/61b9c7efe7bce71f7d2cf3a8?sign=4fe91f6dbbae12ce052674a7a7e8fa7d&t=621ce303', u'thumb': u'http://img5.adesk.com/61b9c7efe7bce71f7d2cf3a8?imageMogr2/thumbnail/!350x540r/gravity/Center/crop/350x540&sign=4fe91f6dbbae12ce052674a7a7e8fa7d&t=621ce303', u'img': u'http://img5.adesk.com/61b9c7efe7bce71f7d2cf3a8?imageMogr2/thumbnail/!1080x1920r/gravity/Center/crop/1080x1920&sign=4fe91f6dbbae12ce052674a7a7e8fa7d&t=621ce303', u'views': 0, u'cid': [u'4e4d610cdf714d2966000000'], u'rule': u'&imageMogr2/thumbnail/!$<Width>x$<Height>r/gravity/Center/crop/$<Width>x$<Height>', u'ncos': 131, u'rank': 87264, u'source_type': u'vertical', u'tag': [u'u7f8eu5973', u'u51acu5929', u'u96eau5730', u'u4f1e', u'u6e05u7eaf'], u'url': [], u'wp': u'http://img5.adesk.com/61b9c7efe7bce71f7d2cf3a8?sign=4fe91f6dbbae12ce052674a7a7e8fa7d&t=621ce303', u'xr': False, u'cr': False, u'favs': 157, u'atime': 1639663507.0, u'id': u'61b9c7efe7bce71f7d2cf3a8', u'store': u'qiniu', u'desc': u''}, {u'preview': u'http://img5.adesk.com/61d69b54e7bce723c6228a34?sign=21592136851fd91093ce09041038a13f&t=621ce303', u'thumb': u'http://img5.adesk.com/61d69b54e7bce723c6228a34?imageMogr2/thumbnail/!350x540r/gravity/Center/crop/350x540&sign=21592136851fd91093ce09041038a13f&t=621ce303', u'img': u'http://img5.adesk.com/61d69b54e7bce723c6228a34?imageMogr2/thumbnail/!1080x1920r/gravity/Center/crop/1080x1920&sign=21592136851fd91093ce09041038a13f&t=621ce303', u'views': 0, u'cid': [u'4e4d610cdf714d2966000000'], u'rule': u'&imageMogr2/thumbnail/!$<Width>x$<Height>r/gravity/Center/crop/$<Width>x$<Height>', u'ncos': 215, u'rank': 95850, u'source_type': u'vertical', u'tag': [], u'url': [], u'wp': u'http://img5.adesk.com/61d69b54e7bce723c6228a34?sign=21592136851fd91093ce09041038a13f&t=621ce303', u'xr': False, u'cr': False, u'favs': 353, u'atime': 1641823506.0, u'id': u'61d69b54e7bce723c6228a34', u'store': u'qiniu', u'desc': u''}]}, u'code': 0}
*/
接下来就要把这些数据中的url提取出来,然后把图片下载到本地了
代码语言:javascript复制#先取出所有链接所在的字典,并将其存储在一个列表当中
info_list = page_text['res']['vertical']
# 定义一个存储图片地址的列表
img_path_list = []
for info in info_list:
img_path_list.append(info['preview'])
#再将所有的图片地址取出,进行下载
#n将作为图片的名字
n = 0
for img_path in img_path_list:
img_data = requests.get(url=img_path,headers=header).content
# 这里是保存的路径,我放到了当前py文件的同一个目录下的fiddler_img文件夹 - mn文件夹
img_path = 'fiddler_img/mn/美女' '_' str(p) '_' str(n) '.jpg'
print img_path '保存成功'
with open(img_path,'wb') as fp:
fp.write(img_data)
n = 1
pn = 30
# 为了有点延迟,这里停了3秒钟哦
time.sleep(3)
那就开始正式爬取图片啦~~~
注:图片路径是手机APP上的高清壁纸直接下载的,之前试过百度壁纸,但是清晰度不太够,如果需要爬取其他分类就需要用fiddler 4去获取手机APP的链接啦
下面就把完整代码贴出来吧~
代码语言:javascript复制#coding=utf-8
import requests
import codecs,time
header = {
'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36'
}
pn = 30
page = 30
for p in range(1, page):
# 美女
url = 'http://service.picasso.adesk.com/v1/vertical/category/4e4d610cdf714d2966000000/vertical?'
# 最新 order: new
# 热门 order: hot
param = {
'limit': 30,
'skip': pn,
'adult': 'false',
'first': 0,
'order': 'hot'
}
#将编码形式转换为utf-8
page_text = requests.get(url=url,headers=header,params=param)
page_text.encoding = 'utf-8'
page_text = page_text.json()
#先取出所有链接所在的字典,并将其存储在一个列表当中
info_list = page_text['res']['vertical']
# 定义一个存储图片地址的列表
img_path_list = []
for info in info_list:
img_path_list.append(info['preview'])
#再将所有的图片地址取出,进行下载
#n将作为图片的名字
n = 0
for img_path in img_path_list:
img_data = requests.get(url=img_path,headers=header).content
img_path = 'fiddler_img/mn/美女' '_' str(p) '_' str(n) '.jpg'
print img_path '保存成功'
with open(img_path,'wb') as fp:
fp.write(img_data)
n = 1
pn = 30
time.sleep(3)
最后,欢迎各位大佬光临我的壁纸小程序哦~
小程序可以直接上传手机中的壁纸哦~