python 阴阳师 识别图像_Python采集阴阳师式神全图鉴图片

https://yys.res.netease.com/pc/zt/20161108171335/data/shishen_big_beforeAwake/201.png

https://yys.res.netease.com/pc/zt/20161108171335/data/shishen_big_afterAwake/201.png

https://yys.res.netease.com/pc/zt/20161108171335/data/shishen_skin/201-1.png

wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==

wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==

多看几张式神的图片后可以发现,每个图片所改变的是式神的 ID 值

可以通过开发者工具抓包,找到数据接口

wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==

请求数据

获得json数据

import requests

url = 'https://yys.res.netease.com/pc/zt/20161108171335/js/app/all_shishen.json'

headers = {

'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36'

}

response = requests.get(url=url, headers=headers)

html_data = response.json()

wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==

解析数据

获取 id 值 以及 式神名字

构建图片地址

for i in html_data:

num_id = i['id']

name = i['name']

beforeAwake = 'https://yys.res.netease.com/pc/zt/20161108171335/data/shishen_big_beforeAwake/{}.png'.format(num_id)

afterAwake = 'https://yys.res.netease.com/pc/zt/20161108171335/data/shishen_big_afterAwake/{}.png'.format(num_id)

skin = 'https://yys.res.netease.com/pc/zt/20161108171335/data/shishen_skin/{}-1.png'.format(num_id)

beforeAwake_response = requests.get(url=beforeAwake, headers=headers)

beforeAwake_name = name + '初始' + '.png'

afterAwake_response = requests.get(url=beforeAwake, headers=headers)

afterAwake_name = name + '觉醒' + '.png'

skin_response = requests.get(url=beforeAwake, headers=headers)

skin_name = name + '皮肤' + '.png'

wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==

保存数据

path = 'D:pythondemo阴阳师img'

def download(name, response):

with open(path + name, mode='wb') as f:

f.write(response.content)

wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==

完整代码

import requests

import pprint

url = 'https://yys.res.netease.com/pc/zt/20161108171335/js/app/all_shishen.json'

path = 'D:pythondemo阴阳师img'

headers = {

'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36'

}

def download(name, response):

with open(path + name, mode='wb') as f:

f.write(response.content)

response = requests.get(url=url, headers=headers)

html_data = response.json()

for i in html_data:

num_id = i['id']

name = i['name']

beforeAwake = 'https://yys.res.netease.com/pc/zt/20161108171335/data/shishen_big_beforeAwake/{}.png'.format(num_id)

afterAwake = 'https://yys.res.netease.com/pc/zt/20161108171335/data/shishen_big_afterAwake/{}.png'.format(num_id)

skin = 'https://yys.res.netease.com/pc/zt/20161108171335/data/shishen_skin/{}-1.png'.format(num_id)

beforeAwake_response = requests.get(url=beforeAwake, headers=headers)

beforeAwake_name = name + '初始' + '.png'

download(beforeAwake_name, beforeAwake_response)

afterAwake_response = requests.get(url=beforeAwake, headers=headers)

afterAwake_name = name + '觉醒' + '.png'

download(afterAwake_name, afterAwake_response)

skin_response = requests.get(url=beforeAwake, headers=headers)

skin_name = name + '皮肤' + '.png'

download(skin_name, skin_response)

print('正在下载{}图鉴'.format(name))

wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==

实现效果

wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==

wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==

wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==

wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==

wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==

你可能感兴趣的:(python,阴阳师,识别图像)