pub struct Client { /* private fields */ }Expand description
Scrapfly API client. Cheap to Clone (the inner reqwest::Client is
Arc’d so all clones share one connection pool).
Implementations§
Source§impl Client
impl Client
Sourcepub fn builder() -> ClientBuilder
pub fn builder() -> ClientBuilder
Start a new ClientBuilder.
Sourcepub fn cloud_browser_host(&self) -> &str
pub fn cloud_browser_host(&self) -> &str
Return the configured Cloud Browser host.
Sourcepub async fn verify_api_key(&self) -> Result<VerifyApiKeyResult, ScrapflyError>
pub async fn verify_api_key(&self) -> Result<VerifyApiKeyResult, ScrapflyError>
Verify the API key by hitting /account.
Sourcepub async fn account(&self) -> Result<AccountData, ScrapflyError>
pub async fn account(&self) -> Result<AccountData, ScrapflyError>
Fetch account info.
Sourcepub async fn scrape(
&self,
config: &ScrapeConfig,
) -> Result<ScrapeResult, ScrapflyError>
pub async fn scrape( &self, config: &ScrapeConfig, ) -> Result<ScrapeResult, ScrapflyError>
Scrape a URL.
Sourcepub fn concurrent_scrape<'a, I>(
&'a self,
configs: I,
concurrency_limit: usize,
) -> impl Stream<Item = Result<ScrapeResult, ScrapflyError>> + 'a
pub fn concurrent_scrape<'a, I>( &'a self, configs: I, concurrency_limit: usize, ) -> impl Stream<Item = Result<ScrapeResult, ScrapflyError>> + 'a
Concurrent-scrape stream. Emits results in completion order.
Sourcepub async fn scrape_proxified(
&self,
config: &ScrapeConfig,
) -> Result<Response, ScrapflyError>
pub async fn scrape_proxified( &self, config: &ScrapeConfig, ) -> Result<Response, ScrapflyError>
Scrape a URL with proxified_response=true, returning the raw
upstream reqwest::Response (target’s status, headers, body).
Unlike [scrape()], no JSON parsing occurs — the response body is
the target page’s raw content. Scrapfly metadata is available on
the X-Scrapfly-* response headers (Api-Cost, Content-Format,
Log, etc.).
Automatically forces proxified_response=true regardless of the
config’s field value.
Sourcepub async fn screenshot(
&self,
config: &ScreenshotConfig,
) -> Result<ScreenshotResult, ScrapflyError>
pub async fn screenshot( &self, config: &ScreenshotConfig, ) -> Result<ScreenshotResult, ScrapflyError>
Screenshot a URL.
Sourcepub async fn extract(
&self,
config: &ExtractionConfig,
) -> Result<ExtractionResult, ScrapflyError>
pub async fn extract( &self, config: &ExtractionConfig, ) -> Result<ExtractionResult, ScrapflyError>
Run AI extraction on a document.
Sourcepub async fn start_crawl(
&self,
config: &CrawlerConfig,
) -> Result<CrawlerStartResponse, ScrapflyError>
pub async fn start_crawl( &self, config: &CrawlerConfig, ) -> Result<CrawlerStartResponse, ScrapflyError>
Schedule a new crawler job.
Sourcepub async fn crawl_status(
&self,
uuid: &str,
) -> Result<CrawlerStatus, ScrapflyError>
pub async fn crawl_status( &self, uuid: &str, ) -> Result<CrawlerStatus, ScrapflyError>
Fetch crawler status.
Sourcepub async fn crawl_urls(
&self,
uuid: &str,
status_filter: Option<&str>,
page: u32,
per_page: u32,
) -> Result<CrawlerUrls, ScrapflyError>
pub async fn crawl_urls( &self, uuid: &str, status_filter: Option<&str>, page: u32, per_page: u32, ) -> Result<CrawlerUrls, ScrapflyError>
List crawled URLs (streaming text endpoint).
Sourcepub async fn crawl_contents_json(
&self,
uuid: &str,
format: CrawlerContentFormat,
limit: Option<u32>,
offset: Option<u32>,
) -> Result<CrawlerContents, ScrapflyError>
pub async fn crawl_contents_json( &self, uuid: &str, format: CrawlerContentFormat, limit: Option<u32>, offset: Option<u32>, ) -> Result<CrawlerContents, ScrapflyError>
Bulk GET /crawl/{uuid}/contents in JSON mode.
Sourcepub async fn crawl_contents_plain(
&self,
uuid: &str,
target_url: &str,
format: CrawlerContentFormat,
) -> Result<String, ScrapflyError>
pub async fn crawl_contents_plain( &self, uuid: &str, target_url: &str, format: CrawlerContentFormat, ) -> Result<String, ScrapflyError>
Plain single-URL GET /crawl/{uuid}/contents?plain=true.
Sourcepub async fn crawl_contents_batch(
&self,
uuid: &str,
urls: &[String],
formats: &[CrawlerContentFormat],
) -> Result<BTreeMap<String, BTreeMap<String, String>>, ScrapflyError>
pub async fn crawl_contents_batch( &self, uuid: &str, urls: &[String], formats: &[CrawlerContentFormat], ) -> Result<BTreeMap<String, BTreeMap<String, String>>, ScrapflyError>
Bulk-batch POST /crawl/{uuid}/contents/batch.
Returns url → format → content (multipart/related response).
Sourcepub async fn crawl_cancel(&self, uuid: &str) -> Result<(), ScrapflyError>
pub async fn crawl_cancel(&self, uuid: &str) -> Result<(), ScrapflyError>
Cancel a crawler job.
Sourcepub async fn crawl_artifact(
&self,
uuid: &str,
artifact_type: CrawlerArtifactType,
) -> Result<CrawlerArtifact, ScrapflyError>
pub async fn crawl_artifact( &self, uuid: &str, artifact_type: CrawlerArtifactType, ) -> Result<CrawlerArtifact, ScrapflyError>
Download a crawler artifact (WARC or HAR).
Source§impl Client
impl Client
Sourcepub fn cloud_browser_url(&self, config: &BrowserConfig) -> String
pub fn cloud_browser_url(&self, config: &BrowserConfig) -> String
Build the WebSocket URL for a new Cloud Browser session.
Sourcepub async fn cloud_browser_unblock(
&self,
config: &UnblockConfig,
) -> Result<UnblockResult, ScrapflyError>
pub async fn cloud_browser_unblock( &self, config: &UnblockConfig, ) -> Result<UnblockResult, ScrapflyError>
Call POST /unblock to bypass anti-bot protection.
Sourcepub async fn cloud_browser_extension_list(&self) -> Result<Value, ScrapflyError>
pub async fn cloud_browser_extension_list(&self) -> Result<Value, ScrapflyError>
List browser extensions for the account.
Sourcepub async fn cloud_browser_extension_get(
&self,
extension_id: &str,
) -> Result<Value, ScrapflyError>
pub async fn cloud_browser_extension_get( &self, extension_id: &str, ) -> Result<Value, ScrapflyError>
Get details of a specific browser extension.
Sourcepub async fn cloud_browser_extension_upload(
&self,
file_path: &Path,
) -> Result<Value, ScrapflyError>
pub async fn cloud_browser_extension_upload( &self, file_path: &Path, ) -> Result<Value, ScrapflyError>
Upload a browser extension from a local file (.zip or .crx).
Sourcepub async fn cloud_browser_extension_delete(
&self,
extension_id: &str,
) -> Result<Value, ScrapflyError>
pub async fn cloud_browser_extension_delete( &self, extension_id: &str, ) -> Result<Value, ScrapflyError>
Delete a browser extension by ID.
Sourcepub async fn cloud_browser_playback(
&self,
run_id: &str,
) -> Result<Value, ScrapflyError>
pub async fn cloud_browser_playback( &self, run_id: &str, ) -> Result<Value, ScrapflyError>
Get debug recording playback metadata for a run.
Sourcepub async fn cloud_browser_session_stop(
&self,
session_id: &str,
) -> Result<(), ScrapflyError>
pub async fn cloud_browser_session_stop( &self, session_id: &str, ) -> Result<(), ScrapflyError>
Terminate a Cloud Browser session.
Sourcepub async fn cloud_browser_sessions(&self) -> Result<Value, ScrapflyError>
pub async fn cloud_browser_sessions(&self) -> Result<Value, ScrapflyError>
List all running Cloud Browser sessions.
Sourcepub async fn cloud_browser_video(
&self,
run_id: &str,
) -> Result<Vec<u8>, ScrapflyError>
pub async fn cloud_browser_video( &self, run_id: &str, ) -> Result<Vec<u8>, ScrapflyError>
Download a debug session recording video (raw bytes).