指令列表
探索可用的浏览指令,以使用 Web Scraper API 自动化动态浏览。
通用参数
下面定义的所有指令具有一组一致的参数。参数如下。
type
type类型:
Enum["click", "input", "scroll", "scroll_to_bottom", "wait", "wait_for_element", "fetch_resource"]描述: 浏览器指令类型。
timeout_s
timeout_s类型:
int描述: 如果操作在规定时间内未完成,多久后跳过该操作。
限制: 0 <
timeout_s<= 60默认值: 5
wait_time_s
wait_time_s类型:
int描述: 在执行下一步操作前等待的时长。
限制: 0 <
wait_time_s<= 60默认值: 0
on_error
on_error类型:
Enum["error", "skip"]描述: 指示在此指令失败时对指令的处理方式:
"error": 停止浏览器指令的执行。"skip": 继续执行下一条指令。
默认值:
"error"
带有通用参数的示例
指令
click
click说明: 点击一个元素并等待设定的秒数。
参数:
type: str = "click"selector: dicttype: Enum["xpath", "css", "text"]value: str
示例:
input
input说明: 在选定的元素中输入文本。
参数:
type: str = "input"selector: dicttype: Enum["xpath", "css", "text"]value: str
value: str示例:
scroll
scroll说明: 向下滚动指定像素数。
参数:
type: str = "scroll"x: inty: int
示例:
scroll_to_bottom
scroll_to_bottom说明: 在设定秒数内滚动到页面底部。
参数:
type: str = "scroll_to_bottom"
示例:
wait
wait说明: 等待设定的秒数。
参数:
type: str = "wait"
示例:
wait_for_element
wait_for_element说明: 在设定秒数内等待元素加载。
参数:
type: str = "wait_for_element"selector: dicttype: Enum["xpath", "css", "text"]value: str
示例:
fetch_resource
fetch_resource该 fetch_resource 该指令必须是浏览器指令列表中的最后一条指令;任何后续指令将不会被执行。
说明: 获取第一个匹配设定模式的 Fetch/XHR 资源。
参数:
type: str = "fetch_resource"filter: str(RegEx expression)on_error: Enum["error", "skip"]
示例:
指令校验
对于指令格式的任何不一致都会导致一个 400 状态码和相应的错误信息。
例如,载荷如下:
将导致:
最后更新于
这有帮助吗?

