import requests
import re
import json
import os
headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"}
def get_pic(pic, path, num):
with open(path + fr"\{num}.jpg","wb+") as f:
f.write(pic)
print(fr"Downloaded {num}!")
def get_hero(txt, num):
name = re.findall("<h2 class=\"cover-name\">(\S*)</h2>", txt)[0]
path = fr"E:\LH\无聊乱搞\二次元\王者皮肤\{name}"
if not os.path.exists(path):
os.makedirs(path)
print(fr"找到{name}!")
for i in range(1,11):
pic_url = fr"https://game.gtimg.cn/images/yxzj/img201606/skin/hero-info/{num}/{num}-bigskin-{i}.jpg"
res = requests.get(pic_url, headers = headers)
if(res.status_code == 200):
pic = res.content
get_pic(pic, path, i)
else:
break
for i in range(100,1000):
hero_url = fr"https://pvp.qq.com/web201605/herodetail/{i}.shtml"
res = requests.get(hero_url, headers = headers)
if(res.status_code == 200):
res.encoding = res.apparent_encoding
txt = res.text
get_hero(txt, i)
Python爬取王者荣耀英雄皮肤
最新推荐文章于 2024-10-12 12:26:23 发布