吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 2296|回复: 34
收起左侧

[Python 原创] 爬取王者荣耀英雄所有皮肤图片

[复制链接]
天轩科技 发表于 2023-8-19 02:52
本帖最后由 天轩科技 于 2023-8-19 03:00 编辑

主要用来练习锻炼编码能力,有一些语法可能写的不是很好,请帮忙指出!谢谢~


hero_style_pic.png
[Python] 纯文本查看 复制代码
import requests, re
from bs4 import BeautifulSoup
url = "https://pvp.qq.com/web201605/herolist.shtml"
headers = {"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Edg/115.0.1901.203",}
html = requests.request("get", url=url, headers=headers).text
soup = BeautifulSoup(html, "lxml")
list = []
for i in soup.find_all(attrs={"class": "herolist clearfix"}):
    for o in i.find_all("a"):
        list.append(f"https://pvp.qq.com/web201605/" + o.get("href"))
count = 1
for ix in list:
    htm = requests.get(url=ix, headers=headers).content
    soup1 = BeautifulSoup(htm, "lxml")
    for img_pf in soup1.find_all(attrs={"class":"pic-pf-list pic-pf-list3"}):
        img_pf_name = img_pf.get('data-imgname').split('|')
        temp_list = []
        for index,pf_no in enumerate(img_pf_name):
            temp_list.append([index+1,pf_no])
        for z in soup1.find_all(attrs={"class": "zk-con1"}):
            Get_style = z.get('style')
            img_url = re.search(r"//.*-",str(Get_style)).group()
            for io in temp_list:
                hero_name = soup1.find(attrs={"class": "cover-name"}).get_text()
                style_name = re.search(r'[\u4e00-\u9fa5]+',str(io[1])).group()
                style_index = (io[0])
                hero_url = f'https:' + str(img_url) + str(style_index) +".jpg"
                pic = requests.get(hero_url).content
                with open(f"{hero_name}-{style_name}.jpg", "wb") as f:
                 f.write(pic)
                print(f"正在下载 === 英雄 :【{hero_name}】 的 【{style_name} 】皮肤图片 ==,这是下载的第{count}张图片。")
                count += 1
print(f"图片下载完毕!总共下载图片为{count}张。")

图片量有点多,上传到123云盘。
下载地址:[color=rgba(0, 0, 0, 0.85)]https://www.123pan.com/s/JQNuVv-KxIw3.html

免费评分

参与人数 8吾爱币 +14 热心值 +7 收起 理由
苏紫方璇 + 7 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!
fauchard + 1 + 1 感谢您的宝贵建议,我们会努力争取做得更好!
shzp + 1 + 1 我很赞同!
tk99 + 1 我很赞同!
zl112233 + 1 用心讨论,共获提升!
zc358 + 1 + 1 我很赞同!
songbing490 + 2 + 1 123网盘分享 必须点赞
为之奈何? + 1 + 1 我很赞同!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

Aragornjf 发表于 2023-8-19 05:35
感谢分享。直接下载了。
zhangxiaoxiao 发表于 2023-8-19 05:54
pjg666 发表于 2023-8-19 06:06
juewangdeyanse 发表于 2023-8-19 07:53
代码默认下载保存的路径怎么设置?
lovekezi 发表于 2023-8-19 07:55
下载后有什么用!
Moondevil 发表于 2023-8-19 08:14
对啊  下载有什么用。   可以玩的时候自嗨下么???
zhuxiangyu1024 发表于 2023-8-19 08:20
把BeautifulSoup换成xpath你会发现要轻松许多。
HD文 发表于 2023-8-19 08:32
大佬,求一个三国杀全部皮肤的压缩包。
 楼主| 天轩科技 发表于 2023-8-19 08:32
HD文 发表于 2023-8-19 08:32
大佬,求一个三国杀全部皮肤的压缩包。

有网址吗》?
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-8 02:47

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表