You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
160 lines
11 KiB
160 lines
11 KiB
import json
|
|
import random
|
|
from enum import Enum
|
|
|
|
import requests
|
|
|
|
|
|
def get_gpuInfo():
|
|
"""
|
|
随机生成设备信息
|
|
:return:
|
|
"""
|
|
random_list = ["Intel(R) Iris(TM) Pro Graphics 5200", "Intel(R) Iris(TM) Graphics 5100",
|
|
"Intel(R) Iris(TM) Graphics 5000", "Intel(R) Iris(TM) Graphics 4200",
|
|
"Intel(R) Iris(TM) Graphics 4400", "Intel(R) Iris(TM) Graphics 4600",
|
|
"Intel(R) Iris(TM) Pro Graphics 6200", "Intel(R) Iris(TM) Pro Graphics 6100",
|
|
"Intel(R) Iris(TM) Graphics 6000", "Intel(R) Iris(TM) Graphics 5500",
|
|
"Intel(R) Iris(TM) Graphics 5300", f"Intel(R) Iris(TM) Graphics {random.randint(100, 999)}"]
|
|
|
|
random_list = [f"Intel(R) Iris(TM) Graphics {random.randint(100, 999)}"]
|
|
gpuInfo = {"glRenderer":"WebKit WebGL","glVendor":"WebKit","unmaskRenderer":f"ANGLE (Intel, ANGLE Metal Renderer: {random.choice(random_list)} Unspecified Version)","unmaskVendor":"Google Inc. (Intel)"}
|
|
|
|
return json.dumps(gpuInfo, separators=(',', ':'))
|
|
|
|
|
|
class BaseHeaders(Enum):
|
|
"""
|
|
|
|
"""
|
|
|
|
# 获取快手session(快手api接口) header
|
|
HEADERS = {
|
|
"Accept-Language": "zh-CN,zh;q=0.9",
|
|
"Cache-Control": "no-cache",
|
|
"Connection": "keep-alive",
|
|
"Origin": "https://www.kuaishou.com",
|
|
"Pragma": "no-cache",
|
|
# "Referer": "https://www.kuaishou.com/profile/3xsdu49r65skedk",
|
|
"Sec-Fetch-Dest": "empty",
|
|
"Sec-Fetch-Mode": "cors",
|
|
"Sec-Fetch-Site": "same-origin",
|
|
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36\",\"userAgent\":\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36",
|
|
"accept": "*/*",
|
|
"content-type": "application/json",
|
|
"sec-ch-ua": "\"Chromium\";v=\"118\", \"Google Chrome\";v=\"118\", \"Not=A?Brand\";v=\"99\"",
|
|
"sec-ch-ua-mobile": "?0",
|
|
"sec-ch-ua-platform": "\"macOS\""
|
|
}
|
|
|
|
# 获取快手过验证码请求headers
|
|
VERIFY_HEADERS = {
|
|
"Accept": "application/json, text/plain, */*",
|
|
"Accept-Language": "zh-CN,zh;q=0.9",
|
|
"Cache-Control": "no-cache",
|
|
"Connection": "keep-alive",
|
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
"Origin": "https://captcha.zt.kuaishou.com",
|
|
"Pragma": "no-cache",
|
|
# "Referer": Referer,
|
|
"Sec-Fetch-Dest": "empty",
|
|
"Sec-Fetch-Mode": "cors",
|
|
"Sec-Fetch-Site": "same-origin",
|
|
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36",
|
|
"sec-ch-ua": "\"Chromium\";v=\"118\", \"Google Chrome\";v=\"118\", \"Not=A?Brand\";v=\"99\"",
|
|
"sec-ch-ua-mobile": "?0",
|
|
"sec-ch-ua-platform": "\"macOS\""
|
|
}
|
|
|
|
PIC_HEADERS = {
|
|
"Accept": "image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8",
|
|
"Accept-Language": "zh-CN,zh;q=0.9",
|
|
"Cache-Control": "no-cache",
|
|
"Connection": "keep-alive",
|
|
"Pragma": "no-cache",
|
|
# "Referer": referer,
|
|
"Sec-Fetch-Dest": "image",
|
|
"Sec-Fetch-Mode": "no-cors",
|
|
"Sec-Fetch-Site": "same-origin",
|
|
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36",
|
|
"sec-ch-ua": "\"Chromium\";v=\"118\", \"Google Chrome\";v=\"118\", \"Not=A?Brand\";v=\"99\"",
|
|
"sec-ch-ua-mobile": "?0",
|
|
"sec-ch-ua-platform": "\"macOS\""
|
|
}
|
|
|
|
DOC_HEADERS = {
|
|
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
|
|
"Accept-Language": "zh-CN,zh;q=0.9",
|
|
"Cache-Control": "no-cache",
|
|
"Connection": "keep-alive",
|
|
"Pragma": "no-cache",
|
|
"Sec-Fetch-Dest": "document",
|
|
"Sec-Fetch-Mode": "navigate",
|
|
"Sec-Fetch-Site": "none",
|
|
"Sec-Fetch-User": "?1",
|
|
"Upgrade-Insecure-Requests": "1",
|
|
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36",
|
|
"sec-ch-ua": "\"Chromium\";v=\"118\", \"Google Chrome\";v=\"118\", \"Not=A?Brand\";v=\"99\"",
|
|
"sec-ch-ua-mobile": "?0",
|
|
"sec-ch-ua-platform": "\"macOS\""
|
|
}
|
|
|
|
|
|
class BaseParam(Enum):
|
|
VERIFY_PARAM = {
|
|
"captchaSn": "",
|
|
"bgDisWidth": 316, # 固定
|
|
"bgDisHeight": 184, # 固定
|
|
"cutDisWidth": 56, # 固定
|
|
"cutDisHeight": 56, # 固定
|
|
"relativeX": "", # 滑动距离 应该是缩放过了
|
|
"relativeY": "", # config接口里的y 缩放 136 * 56/122 ()
|
|
"trajectory": "",
|
|
# "gpuInfo": "{\"glRenderer\":\"WebKit WebGL\",\"glVendor\":\"WebKit\",\"unmaskRenderer\":\"ANGLE (Apple, ANGLE Metal Renderer: Apple M1 Pro, Unspecified Version)\",\"unmaskVendor\":\"Google Inc. (Apple)\"}",
|
|
# "captchaExtraParam": "{\"ua\":\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36\",\"userAgent\":\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36\",\"timeZone\":\"UTC+8\",\"language\":\"zh\",\"cpuCoreCnt\":\"8\",\"platform\":\"MacIntel\",\"riskBrowser\":\"false\",\"webDriver\":\"false\",\"exactRiskBrowser\":\"false\",\"webDriverDeep\":\"false\",\"exactRiskBrowser2\":\"false\",\"webDriverDeep2\":\"false\",\"battery\":\"1\",\"plugins\":\"1a68ba429dd293b14e41a28b6535aa590\",\"resolution\":\"1512x982\",\"pixelDepth\":\"30\",\"colorDepth\":\"30\",\"canvasGraphFingerPrint\":\"10681dead230ee9ca8e67e8ddb0a96013\",\"canvasGraph\":\"10681dead230ee9ca8e67e8ddb0a96013\",\"canvasTextFingerPrintEn\":\"11825830fcdd552d4d3e81af588208d71\",\"canvasTextEn\":\"11825830fcdd552d4d3e81af588208d71\",\"canvasTextFingerPrintZh\":\"19257bc614b1b886224a819517f0715e3\",\"canvasTextZh\":\"19257bc614b1b886224a819517f0715e3\",\"webglGraphFingerPrint\":\"19e85c5151728b98f00fc5a3c6c8bd2dd\",\"webglGraph\":\"19e85c5151728b98f00fc5a3c6c8bd2dd\",\"webglGPUFingerPrint\":\"1777f4110dd337e62088858e6e8df0288\",\"webglGpu\":\"1777f4110dd337e62088858e6e8df0288\",\"cssFontFingerPrintEn\":\"1329bb845104882a7754a3bdf007ff6fc\",\"fontListEn\":\"1329bb845104882a7754a3bdf007ff6fc\",\"cssFontFingerPrintZh\":\"11997d7fc5c7f90fad6abcbadabebb249\",\"fontListZh\":\"11997d7fc5c7f90fad6abcbadabebb249\",\"voiceFingerPrint\":\"14c6f007f1166921565a8aa1c5cfac1c6\",\"audioTriangle\":\"14c6f007f1166921565a8aa1c5cfac1c6\",\"nativeFunc\":\"1973dcbb27a04c3a2ee240d9d2549e105\",\"key1\":\"web_84547d0256a5ac1f023cf5cb911e70a8\",\"key2\":1698917540365,\"key3\":\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36\",\"key4\":\"20030107\",\"key5\":\"zh\",\"key6\":\"Gecko\",\"key7\":1512,\"key8\":982,\"key9\":1512,\"key10\":950,\"key11\":360,\"key12\":360,\"key13\":945,\"key14\":1512,\"key15\":\"00000111\",\"key16\":1,\"key17\":1,\"key18\":[],\"key19\":{},\"key20\":[],\"key21\":{},\"key22\":[],\"key23\":{},\"key24\":[],\"key25\":{},\"key26\":{\"key27\":[\"0,1,21255,58,359,prepare1\",\"1,1,21261,31,332,prepare1\",\"2,1,21268,22,324,prepare1\",\"3,1,21277,5,309,prepare1\",\"4,1,21284,1,306,prepare1\",\"5,1,21600,2,304,prepare1\",\"6,1,21608,6,305,prepare1\",\"7,1,21617,10,306,prepare1\",\"8,1,21627,14,307,prepare1\",\"9,1,21632,20,308,prepare1\",\"10,3,22111,39,307\",\"11,1,22226,39,307,prepare2\",\"12,1,22230,42,307,prepare2\",\"13,1,22239,47,307,prepare2\",\"14,1,22247,53,307,prepare2\",\"15,1,22255,62,307,prepare2\",\"16,1,22264,75,307,prepare2\",\"17,1,22272,88,307,prepare2\",\"18,1,22281,95,307,prepare2\",\"19,1,22289,99,307,prepare2\",\"20,1,22297,105,307,prepare2\",\"21,4,22356,116,307\",\"22,2,22455,116,307,prepare3\",\"23,1,22456,117,307,prepare3\"],\"key28\":[],\"key29\":[],\"key30\":[],\"key31\":{\"prepare1\":\"9,1,21632,20,308\",\"prepare2\":\"20,1,22297,105,307\",\"prepare3\":\"23,1,22456,117,307\"},\"key32\":{},\"key33\":{},\"key34\":{}},\"key35\":\"bf3957c9488bdb2a7a453824e9ee2d6a\",\"key36\":\"f22a94013fc94e90e2af2798023a1985\",\"key37\":2,\"key38\":\"not support\",\"key39\":8}"
|
|
"gpuInfo": get_gpuInfo(),
|
|
"captchaExtraParam": '{"ua":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36","timeZone":"UTC+8","language":"zh-CN","cpuCoreCnt":"2","platform":"MacIntel","riskBrowser":"false","webDriver":"false","exactRiskBrowser":"false","webDriverDeep":"false","exactRiskBrowser2":"false","webDriverDeep2":"false","battery":"1","plugins":"1a68ba429dd293b14e41a28b6535aa590","resolution":"1440x900","pixelDepth":"24","colorDepth":"24","canvasGraphFingerPrint":"170a0a884fada8bac5f9e42250271aaf4","canvasGraph":"170a0a884fada8bac5f9e42250271aaf4","canvasTextFingerPrintEn":"1996477fa0627ebb63c728fa32cacce79","canvasTextEn":"1996477fa0627ebb63c728fa32cacce79","canvasTextFingerPrintZh":"1528ffe56c43c1c514d0de433838f8134","canvasTextZh":"1528ffe56c43c1c514d0de433838f8134","webglGraphFingerPrint":"11a9644c09ae3fd0a918f6f6f712f43c6","webglGraph":"11a9644c09ae3fd0a918f6f6f712f43c6","webglGPUFingerPrint":"1bd896c110303ed46f715b5ac4cbf8329","webglGpu":"1bd896c110303ed46f715b5ac4cbf8329","cssFontFingerPrintEn":"1329bb845104882a7754a3bdf007ff6fc","fontListEn":"1329bb845104882a7754a3bdf007ff6fc","cssFontFingerPrintZh":"11997d7fc5c7f90fad6abcbadabebb249","fontListZh":"11997d7fc5c7f90fad6abcbadabebb249","voiceFingerPrint":"129d646e8a0c62f5c09bead9ff4a0f29d","audioTriangle":"129d646e8a0c62f5c09bead9ff4a0f29d","nativeFunc":"1973dcbb27a04c3a2ee240d9d2549e105"}'
|
|
}
|
|
|
|
|
|
class BaseURL(Enum):
|
|
# nodejs服务
|
|
NodeURL = "http://127.0.0.1:3000/kuaishou/get_verifyParam"
|
|
|
|
|
|
def download_q(url, headers, cookies, data=None, is_proxy=False, timeout=10):
|
|
"""
|
|
下载器
|
|
:param url:
|
|
:param headers:
|
|
:param cookies:
|
|
:param data:
|
|
:param is_proxy:
|
|
:param timeout:
|
|
:return:
|
|
"""
|
|
proxy_list = [] # TODO: 代理
|
|
# proxy = f"{random.choice(proxy_list)}:{random.randint(45001, 45250)}" # 修改代理
|
|
proxy = random.choice(proxy_list)
|
|
proxies = {'http': proxy, 'https': proxy} # 代理初始化
|
|
|
|
if data:
|
|
if is_proxy:
|
|
response = requests.post(url, headers=headers, data=data, proxies=proxies, cookies=cookies, timeout=timeout)
|
|
else:
|
|
response = requests.post(url, headers=headers, data=data, cookies=cookies, timeout=timeout)
|
|
else:
|
|
if is_proxy:
|
|
response = requests.get(url, headers=headers, proxies=proxies, cookies=cookies, timeout=timeout)
|
|
else:
|
|
response = requests.get(url, headers=headers, cookies=cookies, timeout=timeout)
|
|
|
|
return response
|
|
|
|
|
|
def download_pic(path, content):
|
|
with open(path, "wb") as f:
|
|
f.write(content)
|
|
f.close()
|
|
# logger.info(f"图片保存成功 》》》》{path}")
|
|
return path
|