pub struct Tab { /* private fields */ }camoufox only.Expand description
一个浏览器标签页句柄。克隆代价低(共享内核)。
Implementations§
Source§impl Tab
impl Tab
Sourcepub async fn pass_cloudflare_default(&self) -> Result<bool>
pub async fn pass_cloudflare_default(&self) -> Result<bool>
自动通过 Cloudflare 挑战(默认 30s 超时)。见 pass_cloudflare。
Sourcepub async fn pass_cloudflare(&self, timeout: Duration) -> Result<bool>
pub async fn pass_cloudflare(&self, timeout: Duration) -> Result<bool>
在 timeout 内尝试通过 Cloudflare 挑战:
- 已经不是挑战页 → 立即返回
true; - 发现 Turnstile 复选框 → 拟人移动 + 可信点击,等待放行;
- 只有非交互式挑战(无复选框)→ 轮询等待其自动放行。
返回是否在超时内通过。非破坏:不是挑战页时等价于一次轻量探测后立即返回。
Sourcepub async fn is_cloudflare(&self) -> Result<bool>
pub async fn is_cloudflare(&self) -> Result<bool>
当前是否处于 Cloudflare 挑战页(轻量探测,不点击)。
Sourcepub async fn cloudflare_debug(&self) -> Result<Value>
pub async fn cloudflare_debug(&self) -> Result<Value>
CF 诊断信息(页面所有 iframe + 关键标记),用于排查“点歪/没点“。
Source§impl Tab
impl Tab
Sourcepub async fn slider_gap(&self, cfg: &SliderConfig) -> Result<SliderGap>
Available on crate feature slider only.
pub async fn slider_gap(&self, cfg: &SliderConfig) -> Result<SliderGap>
slider only.纯视觉:按 SliderConfig 读图、自动选缺口算法,算出拼图需要水平移动的距离(SliderGap)。
要求验证图已显示。读图失败 / 无有效结果返回 Err。
Sourcepub async fn solve_slider(&self, cfg: &SliderConfig) -> Result<SliderResult>
Available on crate feature slider only.
pub async fn solve_slider(&self, cfg: &SliderConfig) -> Result<SliderResult>
slider only.一把梭:弹出→匹配→闭环拟人拖动→判定→非通过换图重试。返回 SliderResult。
Sourcepub async fn geetest_slide_gap(&self) -> Result<SliderGap>
Available on crate feature slider only.
pub async fn geetest_slide_gap(&self) -> Result<SliderGap>
slider only.极验 v4 滑块缺口(预设 SliderConfig::geetest_v4 的 slider_gap)。
Sourcepub async fn solve_geetest_slide(&self) -> Result<SliderResult>
Available on crate feature slider only.
pub async fn solve_geetest_slide(&self) -> Result<SliderResult>
slider only.一把梭求解极验 v4 滑块(预设 SliderConfig::geetest_v4 的 solve_slider)。
要调尝试次数等用 solve_slider(&SliderConfig::geetest_v4().max_attempts(8))。
Sourcepub async fn dingxiang_slide_gap(&self, index: u32) -> Result<SliderGap>
Available on crate feature slider only.
pub async fn dingxiang_slide_gap(&self, index: u32) -> Result<SliderGap>
slider only.顶象滑块缺口(预设 SliderConfig::dingxiang 的 slider_gap,index=实例后缀)。
Sourcepub async fn solve_dingxiang_slide(
&self,
index: u32,
open: Option<&str>,
) -> Result<SliderResult>
Available on crate feature slider only.
pub async fn solve_dingxiang_slide( &self, index: u32, open: Option<&str>, ) -> Result<SliderResult>
slider only.一把梭求解顶象滑块(预设 SliderConfig::dingxiang)。弹出式传 open 触发按钮(如 #btn-popup)。
注:顶象 demo 对自动化拖动有轨迹/IP 行为风控会弹回(与缺口算法无关);本方法只保证缺口找得准 +
拖到位。要自定义尝试次数等改用 solve_slider(&SliderConfig::dingxiang(i)...)。
Source§impl Tab
impl Tab
Sourcepub async fn storage_state(&self) -> Result<StorageState>
pub async fn storage_state(&self) -> Result<StorageState>
导出当前登录态:全部 cookie + 当前源的 localStorage / sessionStorage。
Sourcepub async fn save_storage_state(&self, path: &str) -> Result<()>
pub async fn save_storage_state(&self, path: &str) -> Result<()>
导出并存盘(JSON)。
Sourcepub async fn load_storage_state(&self, path: &str) -> Result<()>
pub async fn load_storage_state(&self, path: &str) -> Result<()>
从磁盘读回并应用(cookie 全量;storage 仅应用与当前源匹配的那组)。
Sourcepub async fn apply_storage_state(&self, state: &StorageState) -> Result<()>
pub async fn apply_storage_state(&self, state: &StorageState) -> Result<()>
应用一个 StorageState(应用语义同 load_storage_state)。
Source§impl Tab
impl Tab
Sourcepub fn session_id(&self) -> &str
pub fn session_id(&self) -> &str
该标签的 page 会话 id。
Sourcepub fn browser_context_id(&self) -> &str
pub fn browser_context_id(&self) -> &str
该标签独立 BrowserContext 的 id。
Sourcepub async fn get(&self, url: &str) -> Result<bool>
pub async fn get(&self, url: &str) -> Result<bool>
访问网址。返回是否加载成功(DP 语义:bool)。
默认按标签当前加载模式(默认 LoadMode::Normal,等 load)等待;失败不报错,返回 false。
需要重试 / 自定义超时 / 加载模式时用 get_with。
Sourcepub async fn get_with(&self, url: &str, opts: &GetOptions) -> Result<bool>
pub async fn get_with(&self, url: &str, opts: &GetOptions) -> Result<bool>
访问网址(带选项:重试 / 间隔 / 超时 / 加载模式 / referer)。返回是否加载成功。
Sourcepub async fn ax_snapshot(&self) -> Result<AxTree>
pub async fn ax_snapshot(&self) -> Result<AxTree>
DOM 派生的无障碍快照(注入 AX_SNAPSHOT_JS 按 ARIA 规则算):
把页面压成 role "name" 语义树,用于抗改版断言或喂 LLM。与 CDP 后端 ax_snapshot() 同实现、
结果一致(Camoufox 无 CDP 的 Accessibility 域,故不提供 ax_tree() 原生版)。
Sourcepub async fn set_content(&self, html: &str) -> Result<()>
pub async fn set_content(&self, html: &str) -> Result<()>
直接把页面文档内容设为 html(对标 Playwright/Puppeteer set_content;Juggler 无原生命令,走 JS)。
Sourcepub async fn user_agent(&self) -> Result<String>
pub async fn user_agent(&self) -> Result<String>
当前页面的 navigator.userAgent。
Sourcepub async fn ready_state(&self) -> Result<String>
pub async fn ready_state(&self) -> Result<String>
当前 document.readyState(loading/interactive/complete)。
Sourcepub fn url_available(&self) -> bool
pub fn url_available(&self) -> bool
最近一次 get 是否成功(DP 的 url_available)。同步读取,不发协议请求。
Sourcepub async fn stop_loading(&self) -> Result<()>
pub async fn stop_loading(&self) -> Result<()>
停止当前页面加载(等价 JS window.stop();Juggler 无独立 stopLoading 方法)。
Sourcepub async fn wait_loaded(&self) -> Result<bool>
pub async fn wait_loaded(&self) -> Result<bool>
等待文档加载完成(readyState === 'complete')。超时返回 false(不报错)。
Sourcepub async fn handle_next_dialog(
&self,
accept: bool,
prompt_text: Option<&str>,
) -> Result<DialogInfo>
pub async fn handle_next_dialog( &self, accept: bool, prompt_text: Option<&str>, ) -> Result<DialogInfo>
等待并处理下一个 JS 对话框(alert/confirm/prompt/beforeunload)。
accept:确定/取消;prompt_text:prompt 时填入的文本。返回该对话框信息。
若 JS(如 confirm())会阻塞页面,请与触发动作并发调用(见 examples/page_extras)。
Sourcepub async fn set_upload_files(&self, paths: &[&str]) -> Result<()>
pub async fn set_upload_files(&self, paths: &[&str]) -> Result<()>
设置“自然上传“要用的文件并武装文件选择器拦截(对应 DP tab.set.upload_files)。
调用后,下一次任何会弹出文件选择框的点击都不再弹原生窗,而是把这些文件直接填进去。
典型用法:set_upload_files → 点击触发按钮 → wait_upload_paths_inputted。
paths 为本地文件绝对路径(多文件需被触发的 <input> 带 multiple)。
与 Element::set_files 的区别:set_files 直接对已知的 <input type=file> 赋值;本方法处理
“点按钮→系统文件框“这种没有可直接定位的 input(或 input 隐藏、由 JS input.click() 唤起)的场景。
Sourcepub async fn wait_upload_paths_inputted(
&self,
timeout: Option<Duration>,
) -> Result<bool>
pub async fn wait_upload_paths_inputted( &self, timeout: Option<Duration>, ) -> Result<bool>
等待“自然上传“的文件路径被填入(对应 DP tab.wait.upload_paths_inputted)。
配合 set_upload_files + 点击触发使用。timeout=None 用默认超时;
超时返回 false(不报错)。
Sourcepub async fn click(&self, selector: &str) -> Result<()>
pub async fn click(&self, selector: &str) -> Result<()>
便捷:找到并点击(= ele(selector).await?.click().await)。把最常见的「定位 + 点击」合一,
少写一次 .await?。ele 自带超时内等待,故元素稍后才出现也能点到。
Sourcepub async fn input(&self, selector: &str, text: &str) -> Result<()>
pub async fn input(&self, selector: &str, text: &str) -> Result<()>
便捷:找到并输入(= ele(selector).await?.input(text).await)。
需要逐字符拟人输入用 ele(selector).await?.input_human(text);输入前清空用 ele().clear()。
Sourcepub async fn exists(&self, selector: &str) -> Result<bool>
pub async fn exists(&self, selector: &str) -> Result<bool>
元素是否存在(立即判定、不等待)。要“等它出现“用 ele 或
wait().ele_displayed;要静态 HTML 判定用 s_ele。
Sourcepub async fn s_root(&self) -> Result<StaticElement>
pub async fn s_root(&self) -> Result<StaticElement>
解析当前页面 HTML,返回静态根元素(离线解析,不再与浏览器通信)。
Sourcepub async fn s_ele(&self, selector: &str) -> Result<StaticElement>
pub async fn s_ele(&self, selector: &str) -> Result<StaticElement>
解析当前页面 HTML,取第一个匹配的静态元素(DP s_ele)。
适合“抓到页面后批量离线解析“。CSS/@attr/text: 及 xpath:(内置子集)均支持。
Sourcepub async fn s_eles(&self, selector: &str) -> Result<Vec<StaticElement>>
pub async fn s_eles(&self, selector: &str) -> Result<Vec<StaticElement>>
解析当前页面 HTML,取全部匹配的静态元素(DP s_eles)。
Sourcepub async fn get_frame(&self, selector: &str) -> Result<Frame>
pub async fn get_frame(&self, selector: &str) -> Result<Frame>
按定位语法找到一个 <iframe>/<frame> 元素,返回其内容 Frame(DP tab.get_frame)。
Sourcepub async fn paginate<F, Fut, T>(
&self,
next_selector: &str,
max_pages: usize,
f: F,
) -> Result<Vec<T>>
pub async fn paginate<F, Fut, T>( &self, next_selector: &str, max_pages: usize, f: F, ) -> Result<Vec<T>>
翻页采集:对每一页调用 f 收集结果,然后点击 next_selector 翻到下一页,直到
下一页按钮不存在 / 不可点击,或达到 max_pages。返回每页结果(按页序)。
f(page_index) 在当前页就绪后被调用(第 0 页即首屏)。点下一页后会等一小段让新页渲染;
若站点是 AJAX 局部刷新、需要更精确的“等新内容“逻辑,可在 f 内部自行 wait 后再抓。
闭包通常捕获一个 tab.clone() 在内部读元素(避免与本方法的 &self 借用冲突)。
let t = tab.clone();
let pages = tab.paginate("css:.next:not(.disabled)", 10, move |i| {
let t = t.clone();
async move { t.ele("tag:table").await?.table().await }
}).await?;读取本标签(其 BrowserContext)的所有 cookie。
为本标签(其 BrowserContext)设置 cookie。
Sourcepub async fn wait_download(&self, timeout: Duration) -> Result<DownloadInfo>
pub async fn wait_download(&self, timeout: Duration) -> Result<DownloadInfo>
等待本页触发的一次下载完成,返回 DownloadInfo。
需先用 BrowserOptions::download_path 设下载目录。
实现:文件系统跟踪。实测当前 Camoufox/Juggler 构建不下发 Browser.download* 事件,
但文件会可靠落盘(下载中写 <name>.part、完成后改名)。本方法在调用时记录目录基线,然后轮询
等待新出现且写入稳定的文件。因走文件系统,DownloadInfo::url 为空(文件名/路径可用)。
调用顺序:先触发动作、再等(基线在本方法内记录,故 click 在前也可):
link.click().await?;
let info = tab.wait_download(Duration::from_secs(30)).await?; // info.path 即下载到的文件多文件 / 任务列表 / 进度 / 重命名请用句柄式 downloads()。
Sourcepub async fn listen_start(&self, keywords: &[&str]) -> Result<()>
pub async fn listen_start(&self, keywords: &[&str]) -> Result<()>
开始网络监听。keywords 为 URL 子串过滤(空=全部)。
实现:在页面注入 fetch/XHR hook(当前文档 + 后续导航),匹配的请求连同响应体入队,
由 listen_wait/listen_next 取回。
务必在 get 之前调用,以免漏掉早期请求。
Sourcepub async fn listen_xhr(&self, keywords: &[&str]) -> Result<()>
pub async fn listen_xhr(&self, keywords: &[&str]) -> Result<()>
监听(关键词过滤)。hook 天然只覆盖 fetch/XHR,与 listen_start 等价。
Sourcepub async fn listen_wait(&self) -> Result<DataPacket>
pub async fn listen_wait(&self) -> Result<DataPacket>
等待下一个匹配的数据包(带默认超时)。
Sourcepub async fn listen_wait_timeout(&self, timeout: Duration) -> Result<DataPacket>
pub async fn listen_wait_timeout(&self, timeout: Duration) -> Result<DataPacket>
等待下一个匹配的数据包(自定义超时)。供 listen_wait 与
ListenStream 复用。单次模式下会按需 drain;长监听模式下仅从缓冲 pop(后台任务负责 drain)。
Sourcepub async fn listen_next(&self) -> Result<Option<DataPacket>>
pub async fn listen_next(&self) -> Result<Option<DataPacket>>
取下一个数据包(带默认超时;超时返回 None)。
Sourcepub async fn listen_forever(&self) -> Result<()>
pub async fn listen_forever(&self) -> Result<()>
开启长监听:启动后台抽取任务,持续把页面队列搬进本地缓冲(不丢包)。
需先调用 listen_start/listen_xhr 安装 hook。
幂等:重复调用不会重复 spawn。与单次抓取共用同一缓冲,互不冲突。
Sourcepub async fn listen_stream(&self) -> Result<ListenStream>
pub async fn listen_stream(&self) -> Result<ListenStream>
开启长监听并返回一个流式句柄,适合“边滑边持续抓“的场景。
tab.listen_xhr(&["aweme/v1/web/aweme/detail"]).await?;
tab.get(url).await?;
let stream = tab.listen_stream().await?;
while let Some(p) = stream.next_timeout(Duration::from_secs(15)).await? {
// 处理 p ...
tab.press_key("ArrowDown").await?; // 滑到下一个视频
}Sourcepub async fn listen_stop(&self) -> Result<()>
pub async fn listen_stop(&self) -> Result<()>
停止监听并清空状态(同时停掉长监听后台任务)。保留通过 add_init_script
注入的通用脚本(只移除 listen 自己的 hook)。
Sourcepub async fn add_init_script(&self, script: &str) -> Result<()>
pub async fn add_init_script(&self, script: &str) -> Result<()>
添加一个【导航前注入】脚本:在每个新文档最早期(优先于页面自身脚本)执行,并立即在当前 文档执行一次。适合补环境 / 吐环境探针 / 反检测注入。与 listen 的 hook 共存(合并下发)。
务必在 get 之前调用,才能保证新文档里目标脚本运行前探针已就位。
Sourcepub async fn apply_pointer_stealth(&self) -> Result<()>
pub async fn apply_pointer_stealth(&self) -> Result<()>
注入「输入指纹」反检测:把合成 PointerEvent 的空 pointerType 修补成 "mouse"。
背景:经 Page.dispatchMouseEvent 派发的鼠标事件虽是可信事件(isTrusted=true)、也能正确
衍生 movementX/Y、screenX/Y、pressure,但 Firefox/Juggler 从合成鼠标事件衍生的
PointerEvent 的 pointerType 为空串 ""(真实鼠标应为 "mouse")——这是滑块/行为风控
(如 GeeTest)用来识别自动化输入的一个破绽。本方法用一个轻量 getter 补丁把空值改回
"mouse",只改这一处、不动 Function.prototype.toString(不引入更大的可扫描面)。
必须在导航前调用(经 add_init_script 在每个新文档脚本运行前生效)。
Sourcepub async fn press_key(&self, key: &str) -> Result<()>
pub async fn press_key(&self, key: &str) -> Result<()>
模拟按键(keydown+keyup)。内置常用导航键映射;抖音切下一个视频用 press_key("ArrowDown")。
Sourcepub async fn wheel(&self, delta_x: f64, delta_y: f64) -> Result<()>
pub async fn wheel(&self, delta_x: f64, delta_y: f64) -> Result<()>
在视口中心派发鼠标滚轮(deltaY>0 向下)。抖音切视频的备选触发方式。
Sourcepub async fn wheel_at(
&self,
x: f64,
y: f64,
delta_x: f64,
delta_y: f64,
) -> Result<()>
pub async fn wheel_at( &self, x: f64, y: f64, delta_x: f64, delta_y: f64, ) -> Result<()>
在指定坐标派发鼠标滚轮。
Sourcepub async fn scroll_by(&self, x: f64, y: f64) -> Result<()>
pub async fn scroll_by(&self, x: f64, y: f64) -> Result<()>
页面级滚动(window.scrollBy)。普通页面通用;抖音 feed 不一定切视频。
Sourcepub async fn mouse_drag(&self, x: f64, y: f64) -> Result<()>
pub async fn mouse_drag(&self, x: f64, y: f64) -> Result<()>
低层鼠标:按住左键移动到 (x,y)(拖拽过程中的 move,buttons=1)。
Sourcepub fn mouse_move_fast(&self, x: f64, y: f64) -> Result<()>
pub fn mouse_move_fast(&self, x: f64, y: f64) -> Result<()>
低层鼠标(不等待往返):移动到 (x,y)(左键未按下)。
节奏由调用方 sleep 控制,可达真人级 ~10ms 采样;适合拟人轨迹中不需要读返回值的密集移动。
需要边移边读位置(如滑块对齐纠偏)时,仍用会等待的 mouse_move 等。
Sourcepub fn mouse_drag_fast(&self, x: f64, y: f64) -> Result<()>
pub fn mouse_drag_fast(&self, x: f64, y: f64) -> Result<()>
低层鼠标(不等待往返):按住左键移动到 (x,y)(拖拽中的 move,buttons=1)。
Sourcepub fn wait(&self) -> Wait
pub fn wait(&self) -> Wait
等待相关操作的句柄(对应 DP tab.wait):doc_loaded / ele_displayed / ele_loaded / …。
Sourcepub fn scroll(&self) -> Scroll
pub fn scroll(&self) -> Scroll
滚动相关操作的句柄(对应 DP tab.scroll):to_top / to_bottom / to_location / …。
Sourcepub fn set(&self) -> SetTab
pub fn set(&self) -> SetTab
设置相关操作的句柄(对应 DP tab.set):cookies / timeout / load_mode / user_agent。
Sourcepub fn listen(&self) -> Listen
pub fn listen(&self) -> Listen
网络监听句柄(对应 DP tab.listen):start / wait / wait_count / steps / stop。
与扁平的 listen_start/listen_wait/listen_stream/listen_stop 等价(底层复用),
提供更贴近 DrissionPage 的句柄式写法。
Sourcepub fn console(&self) -> Console
pub fn console(&self) -> Console
控制台监听句柄(对应 DP tab.console):start / wait / messages / steps / stop。
基于 Juggler 原生 Runtime.console 事件(不 hook 页面 console,对反检测更友好)。
console.log() 等输出到控制台的内容才能获取。
Sourcepub fn websocket(&self) -> WsListener
pub fn websocket(&self) -> WsListener
WebSocket 帧监听句柄(drission-rs 增强):start / wait / wait_count / messages /
sockets / steps / stop。
基于 Juggler 原生 Page.webSocket* 事件(不 hook 页面 WebSocket,对反检测更友好):
抓取页面 WebSocket 收发的每一帧(文本 / 二进制)。务必在建立连接之前 start()。
let ws = tab.websocket();
ws.start_with(WsFilter::new().url_contains("/im/")).await?;
tab.get(url).await?;
while let Some(m) = ws.wait(Some(Duration::from_secs(10))).await? {
if m.is_text() { println!("{} {}", m.direction.as_str(), m.text().unwrap()); }
}Sourcepub fn actions(&self) -> Actions
pub fn actions(&self) -> Actions
动作链(对应 DP tab.actions / Selenium ActionChains):把鼠标/键盘动作链式串起来,
perform().await 一次执行。最典型用途是拖放:
tab.actions().move_to_ele(&src).hold().move_to_ele(&dst).release().perform().await?;Sourcepub fn intercept(&self) -> Intercept
pub fn intercept(&self) -> Intercept
请求拦截句柄(对应 DP 风格;与 listen()/console()/websocket() 句柄风格统一)。
把扁平的 intercept_start/intercept_xhr/intercept_next/intercept_stop 收敛成句柄式
(底层完全复用,不改变既有行为):
tab.intercept().start(&["/api/"]).await?; // 务必在 get 之前
tab.get(url).await?;
let req = tab.intercept().next().await?; // 取一个被拦请求
req.fulfill(200, vec![], "{\"ok\":true}").await?; // 伪造响应(或 resume/abort/resume_with)
tab.intercept().stop().await?;Sourcepub fn downloads(&self) -> Downloads
pub fn downloads(&self) -> Downloads
下载管理句柄(对标 DP DownloadManager):start/wait_done/wait_count_done/missions/stop。
后台收集本标签触发的多个下载,支持任务列表、自定义重命名([DownloadMission::save_as])、
best-effort 进度([DownloadMission::downloaded_bytes])。需先用
BrowserOptions::download_path 设下载目录。
一次性等单个下载用 wait_download 即可。
Sourcepub fn screencast(&self) -> Screencast
pub fn screencast(&self) -> Screencast
录像句柄(对应 DP tab.screencast):set_save_path / set_mode / set_fps / start / stop。
大道至简实现 = 后台按帧间隔反复截视口存帧;Video 模式停止时用 ffmpeg 合成 mp4。
let cast = tab.screencast();
cast.set_save_path("video").set_mode(ScreencastMode::Imgs).set_fps(10.0);
cast.start(None).await?;
tab.wait().secs(3.0).await;
let out = cast.stop().await?; // 帧目录(imgs)或 mp4(video)Sourcepub async fn screenshot_bytes(&self, full_page: bool) -> Result<Vec<u8>>
pub async fn screenshot_bytes(&self, full_page: bool) -> Result<Vec<u8>>
截图,返回 PNG 字节。full_page=true 截整页(按文档滚动尺寸),否则截当前视口。
要 JPEG / 指定区域 / 调质量,用 screenshot + ShotOpts。
Sourcepub async fn screenshot_base64(&self, full_page: bool) -> Result<String>
pub async fn screenshot_base64(&self, full_page: bool) -> Result<String>
截图,返回 base64 字符串(对应 DP get_screenshot(as_base64=...))。默认 PNG。
Sourcepub async fn get_screenshot(
&self,
path: impl AsRef<Path>,
full_page: bool,
) -> Result<PathBuf>
pub async fn get_screenshot( &self, path: impl AsRef<Path>, full_page: bool, ) -> Result<PathBuf>
截图并保存到 path。格式按 path 后缀自动选(.jpg/.jpeg→JPEG,其余 PNG)。
返回写入的路径;父目录不存在会自动创建。
Sourcepub async fn intercept_start(&self, keywords: &[&str]) -> Result<()>
pub async fn intercept_start(&self, keywords: &[&str]) -> Result<()>
开始请求拦截。keywords 为 URL 子串过滤(空=拦截所有请求)。
匹配过滤的请求通过 intercept_next 交给你决策
(放行 / 改写 / 伪造 / 中止);不匹配的请求由库自动放行,避免页面卡死。
Sourcepub async fn intercept_xhr(&self, keywords: &[&str]) -> Result<()>
pub async fn intercept_xhr(&self, keywords: &[&str]) -> Result<()>
仅拦截 XHR/fetch 类请求(其余自动放行)。
Sourcepub async fn intercept_next(&self) -> Result<InterceptedRequest>
pub async fn intercept_next(&self) -> Result<InterceptedRequest>
等待下一个被拦截的请求(带默认超时)。拿到后必须调用其
resume / resume_with / fulfill / abort 之一放行。
Sourcepub async fn intercept_next_timeout(
&self,
timeout: Duration,
) -> Result<Option<InterceptedRequest>>
pub async fn intercept_next_timeout( &self, timeout: Duration, ) -> Result<Option<InterceptedRequest>>
等待下一个被拦截的请求(自定义超时;超时返回 None,不报错)。
Sourcepub async fn intercept_stop(&self) -> Result<()>
pub async fn intercept_stop(&self) -> Result<()>
停止拦截并清空状态。
Trait Implementations§
Source§impl EnvBackend for Tab
impl EnvBackend for Tab
Source§impl FingerprintProbe for Tab
impl FingerprintProbe for Tab
Source§fn fp_eval<'life0, 'life1, 'async_trait>(
&'life0 self,
js: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn fp_eval<'life0, 'life1, 'async_trait>(
&'life0 self,
js: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
run_js)。Source§fn fingerprint_snapshot<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<FingerprintSnapshot>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn fingerprint_snapshot<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<FingerprintSnapshot>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
FingerprintSnapshot。 Read moreSource§impl Humanize for Tab
impl Humanize for Tab
Source§fn hm_move<'life0, 'async_trait>(
&'life0 self,
x: f64,
y: f64,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn hm_move<'life0, 'async_trait>(
&'life0 self,
x: f64,
y: f64,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn hm_move_fast<'life0, 'async_trait>(
&'life0 self,
x: f64,
y: f64,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn hm_move_fast<'life0, 'async_trait>(
&'life0 self,
x: f64,
y: f64,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
hm_move(等往返),CDP/Camoufox 覆盖为
fire 快路径——这是轨迹“时间密度“的关键:等往返会把每点间隔抻到 ~20–40ms(行为风控破绽),
fire 由 sleep 控节奏可达 ~50–100Hz,逼近真人(见里程碑 32/61)。fn hm_down<'life0, 'async_trait>(
&'life0 self,
x: f64,
y: f64,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn hm_up<'life0, 'async_trait>(
&'life0 self,
x: f64,
y: f64,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn hm_eval<'life0, 'life1, 'async_trait>(
&'life0 self,
js: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn image_view<'life0, 'life1, 'async_trait>(
&'life0 self,
selector: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<ImageView>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn image_view<'life0, 'life1, 'async_trait>(
&'life0 self,
selector: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<ImageView>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
selector 元素的 ImageView(显示 rect + 自然尺寸 + src),用于像素→页面映射与取源图。Source§fn human_click<'life0, 'life1, 'async_trait>(
&'life0 self,
points: &'life1 [(f64, f64)],
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn human_click<'life0, 'life1, 'async_trait>(
&'life0 self,
points: &'life1 [(f64, f64)],
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn human_click_with<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
points: &'life1 [(f64, f64)],
opts: &'life2 HumanClickOpts,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn human_click_with<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
points: &'life1 [(f64, f64)],
opts: &'life2 HumanClickOpts,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Auto Trait Implementations§
impl !RefUnwindSafe for Tab
impl !UnwindSafe for Tab
impl Freeze for Tab
impl Send for Tab
impl Sync for Tab
impl Unpin for Tab
impl UnsafeUnpin for Tab
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> CloneAny for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more