AutoScript Hub 脚本开发 SDK —— 一行导入,获取浏览器、代理、输出目录等所有运行时变量
Project description
autoscript-hub-sdk
AutoScript Hub 脚本开发 SDK —— 一行导入,获取浏览器、代理、输出目录等所有运行时变量。
安装
pip install autoscript-hub-sdk
快速开始
from autoscript_hub_sdk import env
# 浏览器配置
print(env.browser_port) # 9222(调试端口)
print(env.browser_path) # "C:\\Program Files\\Google\\Chrome\\..."
# 目录
print(env.output_dir) # "D:\\output"
print(env.script_dir) # 当前脚本所在目录
# 网络
print(env.proxy) # "http://127.0.0.1:7890"
# 脚本参数(用户在表单中填写的值)
print(env.params) # {"keyword": "手机", "page": 1}
# 自定义环境变量(环境管理 → 高级设置 → extra_env)
api_key = env.get("MY_API_KEY", "默认值")
两种导入方式
方式一:导入 env 对象(推荐)
from autoscript_hub_sdk import env
port = env.browser_port
方式二:直接导入变量
from autoscript_hub_sdk import browser_port, browser_path, output_dir, proxy
在 AutoScript Hub 中使用
在脚本的 config() 中声明依赖即可,Agent 会自动安装:
def config():
return {
"name": "我的脚本",
"version": "1.0.0",
"requirements": ["autoscript-hub-sdk", "DrissionPage>=4.0"],
"params": [...],
}
def main(keyword="", page=1):
from autoscript_hub_sdk import env
print(f"浏览器端口: {env.browser_port}")
print(f"输出目录: {env.output_dir}")
print(f"参数: keyword={keyword}, page={page}")
所有可用变量
| 属性 | 类型 | 环境变量 | 说明 |
|---|---|---|---|
env.browser_port |
int | None |
BROWSER_PORT |
浏览器调试端口 |
env.browser_path |
str | None |
BROWSER_PATH |
浏览器路径 |
env.output_dir |
str |
OUTPUT_DIR |
输出目录 |
env.script_dir |
str |
— | 脚本所在目录 |
env.proxy |
str | None |
http_proxy |
代理地址 |
env.params |
dict |
— | 脚本参数 |
env.get(key) |
any |
自定义 | 任意环境变量 |
开发 & 发布
cd sdk
pip install build
python -m build
pip install twine
twine upload dist/*
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file autoscript_hub_sdk-1.0.0.tar.gz.
File metadata
- Download URL: autoscript_hub_sdk-1.0.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cff67a1bd8cdc28b4b61f6d72c3417e41849deee032c27bc321c9776d710a990
|
|
| MD5 |
9c1095c8837773cb7a38dd772d4b4af5
|
|
| BLAKE2b-256 |
639abf57f86ab5fad9f6ae66fe8e4184d18c47c6e2c0547982af1d9f5030b043
|
File details
Details for the file autoscript_hub_sdk-1.0.0-py3-none-any.whl.
File metadata
- Download URL: autoscript_hub_sdk-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
555f2a6e93fcd9a8c23af6761b52aa48c5ead3e8022c58998fab3c3730b51d59
|
|
| MD5 |
c9aed4e355266e8007d7da65e262da1d
|
|
| BLAKE2b-256 |
2042fea3da11cf6f3e571caa7a9e3d76d78539fdcb5c8b9b957a74505c3a4229
|