vb保存she皮肤
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vb保存she皮肤相关的知识,希望对你有一定的参考价值。
在一个窗体中用 SkinH_AttachEx App.Path & "/123.she", "" 加载皮肤。但想用几种颜色可选择。选中一种皮肤后,下次运行还能保存上次选的皮肤,而不是默认的皮肤
首先啊。你把加载皮肤的路径放在一个变量中比如
dim a as string
a = App.Path & "/123.she"
SkinH_AttachEx a, ""
然后把变量a也就是路径写入一个文件中
Dim sssa As String * 1000
Dim str2 As String
fn = App.Path & "\" & "HJonny" & ".dll"
sssa = a
If Dir(fn) <> "" Then
Kill fn
End If
Open fn For Binary As #1
Put #1, , sssa '写入数据
Close #1 '关闭
这样就把路径写在一个文件中了。
当窗口载入的时候在加入如下代码
Private Sub Form_Load()
Dim sssa As String * 1000
Dim str2 As String
fn = App.Path & "\" & "HJonny" & ".dll"
If Dir(fn) <> "" Then
Open fn For Binary As #2
Get #2, , sssa
Close #2
str2 = Trim(sssa)
SkinH_AttachEx str2, ""
End Sub
这样就行了。希望能对你有帮助 参考技术A 将路径或参数存到注册表,下次运行时候,从注册表读取。追问
能否给个实例源码,我的QQ是770614208 你加我在教我吧,谢谢了!
备注 百度知道
教你用python爬取王者荣耀英雄皮肤图片,并将图片保存在各自英雄的文件夹中。(附源码)
教你用python爬取王者荣耀英雄皮肤图片,并将图片保存在各自英雄的文件夹中。(附源码)
代码展示:
保存在各自的文件夹中
美么?
让我们开始爬虫之路
开发环境
windows 10
python3.6
开发工具
pycharm
webdriver
库
os,re,lxml,jsonpath
打开王者荣耀官网点击游戏资料
判断是同步加载还是异步加载, 可以确定为异步加载
点击XHR继续抓包,ename为英雄的ID,cname为英雄的名字
jsonpath获取
# 第一次请求,获取hero_id hero_name
response = requests.get(start_url, headers=headers).json()
# pprint(response)
hero_ids = jsonpath.jsonpath(response, '$..ename')
# pprint(hero_ids)
hero_names = jsonpath.jsonpath(response, '$..cname')
# pprint(hero_names)
构造英雄地址
hero_info_url = r’https://pvp.qq.com/web201605/herodetail/{}.shtml’.format(hero_id)
driver访问每一个英雄地址,获取源码,etree解析,xpath提取hero_skin_names,hero_skin_urls
for hero_name, hero_id in zip(hero_names, hero_ids):
hero_info_url = r'https://pvp.qq.com/web201605/herodetail/{}.shtml'.format(hero_id)
# 发送英雄详情页请求得到 hero_info_content
driver.get(hero_info_url)
# 获取页面源码
hero_info_content = driver.page_source
# 解析网页
hero_info_content_str = etree.HTML(hero_info_content)
# 提取 hero_skin_names hero_skin_urls
hero_skin_names = hero_info_content_str.xpath(r'//ul[@class="pic-pf-list pic-pf-list3"]/@data-imgname')[
0].split('|')
hero_skin_urls = hero_info_content_str.xpath(r'//ul[@class="pic-pf-list pic-pf-list3"]//img/@data-imgname')
遍历hero_skin_urls地址,获取图片的二进制数据,最后进行保存,创建英雄的文件夹,将皮肤图片保存在各自的文件夹中
# 补全hero_skin_url地址
hero_skin_url = r'https:'+hero_skin_url
# 获取图片的二进制信息
img_content = requests.get(hero_skin_url, headers=headers).content
try:
# 创建文件夹
if not os.path.exists('./{}'.format(hero_name)):
os.mkdir(r'./{}'.format(hero_name))
with open(r'./{}/{}.jpg'.format(hero_name, hero_skin_name), 'wb')as f:
f.write(img_content)
print('图片正在下载:{}/{}.jpg'.format(hero_name, hero_skin_name))
except Exception as e:
continue
在执行时本来是以requests库进行获取英雄页面的源码,但是发生报错,报错原因是因为编码问题,所以采用webdriver访问每个英雄页面,driver.page_source获取源码,然后进行数据提取。
源码展示
# !/usr/bin/nev python
# -*-coding:utf8-*-
import requests, os, jsonpath, re
from selenium import webdriver
from pprint import pprint
from lxml import etree
def main():
start_url = r'https://pvp.qq.com/web201605/js/herolist.json'
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/87.0.4280.88 Safari/537.36',
'Referer': 'https://pvp.qq.com/web201605/herolist.shtml'
}
driver = webdriver.Chrome(executable_path=r'D:\\python\\chromedriver.exe')
# 第一次请求,获取hero_id hero_name hero_skin_names
response = requests.get(start_url, headers=headers).json()
# pprint(response)
hero_ids = jsonpath.jsonpath(response, '$..ename')
# pprint(hero_ids)
hero_names = jsonpath.jsonpath(response, '$..cname')
# pprint(hero_names)
for hero_name, hero_id in zip(hero_names, hero_ids):
hero_info_url = r'https://pvp.qq.com/web201605/herodetail/{}.shtml'.format(hero_id)
# 发送英雄详情页请求得到 hero_info_content
driver.get(hero_info_url)
# 获取页面源码
hero_info_content = driver.page_source
# lxml解析
hero_info_content_str = etree.HTML(hero_info_content)
# 提取 hero_skin_names hero_skin_urls
hero_skin_names = hero_info_content_str.xpath(r'//ul[@class="pic-pf-list pic-pf-list3"]/@data-imgname')[
0].split('|')
hero_skin_urls = hero_info_content_str.xpath(r'//ul[@class="pic-pf-list pic-pf-list3"]//img/@data-imgname')
# hero_skin_name进行替换不必要的信息
for hero_skin_name, hero_skin_url in zip(hero_skin_names, hero_skin_urls):
suffix_notation = re.findall(r'&\\d.?', hero_skin_name)[0]
hero_skin_name = hero_skin_name.replace(suffix_notation, '')
# 补全hero_skin_url地址
hero_skin_url = r'https:'+hero_skin_url
# 获取图片的二进制信息
img_content = requests.get(hero_skin_url, headers=headers).content
try:
# 创建文件夹
if not os.path.exists('./{}'.format(hero_name)):
os.mkdir(r'./{}'.format(hero_name))
with open(r'./{}/{}.jpg'.format(hero_name, hero_skin_name), 'wb')as f:
f.write(img_content)
print('图片正在下载:{}/{}.jpg'.format(hero_name, hero_skin_name))
except Exception as e:
continue
if __name__ == '__main__':
main()
代码仅供学习,欢迎一键三连,感谢各位的支持!
祝大家学习python顺利!
以上是关于vb保存she皮肤的主要内容,如果未能解决你的问题,请参考以下文章
教你用python爬取王者荣耀英雄皮肤图片,并将图片保存在各自英雄的文件夹中。(附源码)