2020-08-13|2020-08-13 同花顺证书批量下载
exe下载地址
https://github.com/realhanlin/WorkRepo.git
0 背景
同花顺公司后台服务需要授权证书文件方可正常运行。
交易主站3个证书,行情2个证书,接入主站4个证书,所有服务器会涉及200+证书。官方无批量下载功能,遂编写此工具。V1.* python2版本已废弃,V2为2020年python3版本。
1 思路
1.1 找到下载链接
证书下载网站如下
http://services.myhexin.com/produser/querycert
经过F12调试分析,得出下载链接如下:
http://services.myhexin.com/produser/downloadcert?libver=20030506&authcode=M11-ics3-JqUK-0Lab-%2FwIY-HTRL&Submit=%CF%C2%D4%D8%D6%A4%CA%E9
1.2 分析出各个入参
url_base = 'http://services.myhexin.com/produser/downloadcert'
url_data = https://www.it610.com/article/{"libver": '20030506',
"authcode": 'M11-ics3-JqUK-0Lab-/wIY-HTRL',
"Submit": '下载证书'}
1.3 json保存编码信息,urllib下载证书
通过json文件保存IP和证书编码列表,然后用自写的ThsCertSave类下载证书到如下目录中
文章图片
image.png 2 附录 2.1 py脚本
#!/usr/bin/python
# Download ths cert files
# Ver 2.0
# Edit By hanlin @Beijingimport os
import json
import urllib
from urllib.request import urlopen
from urllib.request import Request
from urllib.parse import urlencode
from urllib.parse import quoteclass ThsCertSave:
path = ''
ip = ''
codelist = []
url_base = ''
url_datahttps://www.it610.com/article/= ''
def __init__(self,path,ip,codelist,url_base,url_data):
self.path = path
self.ip = ip
self.codelist = codelist
self.url_base = url_base
self.url_data = https://www.it610.com/article/url_data
def __createPathName(self,code):
file_name = code.split('-')[0] + '.dat'
if not os.path.exists(self.path + self.ip):
os.makedirs(self.path + self.ip)
path_file = self.path + self.ip + '/' + file_name
return path_file
def __iUrlEncode(self,code):
# special process for Chinese Char
data_cn = self.url_data["Submit"].encode('gb2312')
data_cn = quote(data_cn)
self.url_data["Submit"] = '123'
req_data = https://www.it610.com/article/urlencode(self.url_data)
req_data = req_data.replace('123', data_cn)
iurl = self.url_base + '?' + req_data
return iurldef save(self):
for code in self.codelist:
path_file = self.__createPathName(code)
iurl = self.__iUrlEncode(code)
res = urlopen(iurl)
with open(path_file,"wb") as mydat:
mydat.write(res.read())
print('Saving: '+path_file)def main():
path = './download/'
url_base = 'http://services.myhexin.com/produser/downloadcert'
url_data = https://www.it610.com/article/{"libver": '20030506',
"authcode": 'M11-ics3-JqUK-0Lab-/wIY-HTRL',
"Submit": '下载证书'}
#is_json = is_json.is_json('ths.json')
with open('ths.json', 'r') as f:
ths_data = https://www.it610.com/article/json.load(f)ip_list = ths_data.keys()
for ip in ip_list:
isave = ThsCertSave(path,ip,ths_data[ip],url_base,url_data)
isave.save()if __name__ =="__main__":
main()
2.2 json文件
{
"172.1.100.48":["M11-ics3-JqUK-****-/wIY-HTRL","M21-ics3-***-0Lab-/wIY-HTRL","M31-***-JqUK-0Lab-/wIY-HTRL","M41-ics3-***-0Lab-/wIY-HTRL"],
"172.1.100.57":["E11-HEzV-****-2k+o-ZchK-Wlab"],
"172.1.100.69":["E11-****-wUIc-+u8P-OSS6-jtMg","E21-KY6o-wUIc-+****-OSS6-jtMg"]
}
【2020-08-13|2020-08-13 同花顺证书批量下载】pyinstaller-develop打包exe文件:python pyinstaller.py -F --icon="me.ico" demo.py
推荐阅读
- 劳协证书已出,如何办理劳协持证入户()
- 360|360 将停止 StartCom 数字证书业务;微软的 Visual Studio Tools for AI 现已提供使用
- 参考站点
- Mac开发下的各种证书
- linux安装docker并实现idea使用证书加密连接
- burpsuit谷歌浏览器代理证书及HSTS处理
- 注意!自2022年7月1日起,Sectigo证书将弃用OU字段
- Mac 上制作 SSL 证书
- 通配符SSL证书选购攻略
- SSL证书格式及转化方法