指令列表

Web Unblocker 支持的完整浏览器指令列表及示例。

通用参数

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

type

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

  • 描述: 浏览器指令类型。

timeout_s

  • 类型: 整数

  • 描述: 如果未在规定时间内完成,多久后跳过该动作。

  • 限制: 0 < timeout_s <= 60

  • 默认值: 5

wait_time_s

  • 类型: 整数

  • 描述: 在执行下一个动作前等待多长时间。

  • 限制: 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

  • 示例:

input

  • 描述:在选定元素中输入文本。

  • 参数:

    • type: str = "input"

    • selector: dict

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

      • value: str

    • value: str

    • 示例:

scroll

  • 描述:滚动指定像素数。

  • 参数:

    • type: str = "scroll"

    • x: 整数

    • y: 整数

  • 示例:

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 状态码和相应的错误信息。

例如,像这样的负载:

将导致:

最后更新于

这有帮助吗?