本文最后更新于 2025-08-25T15:59:28+08:00
引包方式
在引包 部署时 总会出现路径问题,包括execjs的路径
万能导入引包
1 2 3 4
| import sys import os
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
|
或者
1 2 3 4 5 6 7
| import sys import os
script_path = os.path.abspath(os.path.dirname(__file__) + "./..") if script_path not in sys.path: sys.path.append(script_path)
|
万能路径
1 2 3 4
| from pathlib import Path
current_path = Path.cwd() file_path = current_path / "aaaa" / "bbb.js"
|
提取json
类似于下文这样的JSON提取出JSON
VaptchaJsonp1756106013582({“code”: “0103”,”data”: {“knock”:”1756107661vbymKE2e12d”,”cdn_servers”:[“static-cn.vaptcha.net”],”css_version”:”2.9.12”,”js_path”:”verify.2.2.4.js”,”help”:true,”is_vip”:-1,”guideVersion”:”3.1.0”,”sdk_ver”:”vaptcha-sdk.1.2.35.669f69e6.js”,”net_way”:-1,”node”:”CN”,”server”:”https://0.vaptcha.com/verify"},"msg":""})
1
| extract_json = lambda s: json.loads(s[s.find('{'):s.rfind('}') + 1])
|
添加代理
1 2 3 4
| proxies = lambda authKey="xxx", password="xxx", proxyAddr="xxxx:xxx": { "http": f"http://{authKey}:{password}@{proxyAddr}", "https": f"http://{authKey}:{password}@{proxyAddr}", }
|