指令列表

网页解锁器 支持的浏览器指令完整列表及示例。

通用参数

下面定义的所有指令都具有一组一致的参数。参数如下。

type

  • 类型: Enum["click", "input", "scroll", "scroll_to_bottom", "wait", "wait_for_element", "fetch_resource"]

  • 说明: 浏览器指令类型。

timeout_s

  • 类型: int

  • 说明: 如果未能按时完成,动作在多久后被跳过。

  • 限制: 0 < timeout_s <= 60

  • 默认值: 5

wait_time_s

  • 类型: int

  • 说明: 执行下一步动作前等待多久。

  • 限制: 0 < wait_time_s <= 60

  • 默认值: 0

on_error

  • 类型: Enum["error", "skip"]

  • 说明: 指示当此指令失败时如何处理指令:

    • "error": 停止执行浏览器指令。

    • "skip": 继续执行下一条指令。

  • 默认值: "error"

通用参数示例

指令

click

  • 说明: 点击一个元素并等待指定秒数。

  • 参数:

    • type: str = "click"

    • selector: dict

      • type: Enum["xpath", "css", "text"]

      • value: str

  • 示例:

输入

  • 说明: 向选中的元素输入文本。

  • 参数:

    • type: str = "input"

    • selector: dict

      • type: Enum["xpath", "css", "text"]

      • value: str

    • value: str

    • 示例:

滚动

  • 说明: 按指定像素数滚动。

  • 参数:

    • type: str = "scroll"

    • x: int

    • y: int

  • 示例:

scroll_to_bottom

  • 说明: 滚动到底部,持续指定秒数。

  • 参数:

    • type: str = "scroll_to_bottom"

  • 示例:

wait

  • 说明: 等待指定秒数。

  • 参数:

    • type: str = "wait"

  • 示例:

wait_for_element

  • 说明: 等待元素加载,持续指定秒数。

  • 参数:

    • type: str = "wait_for_element"

    • selector: dict

      • type: Enum["xpath", "css", "text"]

      • value: str

    • 示例:

fetch_resource

  • 说明: 获取与指定模式匹配的第一个 Fetch/XHR 资源。

  • 参数:

    • type: str = "fetch_resource"

    • filter: str(RegEx expression)

    • on_error: Enum["error", "skip"]

  • 示例:

指令验证

任何关于指令格式的不一致都会导致一个 400 状态码和相应的错误消息。

例如,如下载荷:

将导致:

这有帮助吗?