pub struct ScrapeRequest {
pub website_url: String,
pub clean: Option<bool>,
pub parse_mode: Option<ParseMode>,
pub tag_truncate: Option<bool>,
pub extract_links: Option<bool>,
pub include_tags: Option<Vec<String>>,
pub exclude_tags: Option<Vec<String>>,
pub headers: Option<HashMap<String, String>>,
pub max_age: Option<u64>,
pub stealth: Option<bool>,
}Expand description
Request body for Client::scrape.
Build with ScrapeRequest::new and chain the option setters; only fields
you touch are serialized.
use webscrape_ai::ScrapeRequest;
let req = ScrapeRequest::new("https://example.com").clean(true).extract_links(true);
let json = serde_json::to_value(&req).unwrap();
assert_eq!(json["website_url"], "https://example.com");
assert_eq!(json["clean"], true);
assert!(json.get("tag_truncate").is_none()); // untouched -> absentFields§
§website_url: StringThe URL to fetch. Required.
clean: Option<bool>Convert HTML to cleaned markdown.
parse_mode: Option<ParseMode>Cleaner mode when clean.
tag_truncate: Option<bool>Replace inline images with alt text when clean (tri-state).
extract_links: Option<bool>Include a deduplicated list of outbound links.
Whitelist of tags to keep when clean.
Blacklist of tags to drop when clean.
headers: Option<HashMap<String, String>>Custom request headers; providing any disables URL caching.
max_age: Option<u64>URL-cache opt-in in seconds (tri-state; omitted = fetch fresh).
stealth: Option<bool>Browser-based stealth fetch. +2 credits.
Implementations§
Source§impl ScrapeRequest
impl ScrapeRequest
Sourcepub fn parse_mode(self, mode: ParseMode) -> Self
pub fn parse_mode(self, mode: ParseMode) -> Self
Set the cleaner mode.
Sourcepub fn tag_truncate(self, tag_truncate: bool) -> Self
pub fn tag_truncate(self, tag_truncate: bool) -> Self
Replace inline images with alt text when cleaning.
Sourcepub fn extract_links(self, extract_links: bool) -> Self
pub fn extract_links(self, extract_links: bool) -> Self
Include a deduplicated list of outbound links.
Set the tag whitelist.
Set the tag blacklist.
Sourcepub fn header(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn header(self, key: impl Into<String>, value: impl Into<String>) -> Self
Add a single custom request header.
Sourcepub fn headers(self, headers: HashMap<String, String>) -> Self
pub fn headers(self, headers: HashMap<String, String>) -> Self
Replace all custom request headers.
Trait Implementations§
Source§impl Clone for ScrapeRequest
impl Clone for ScrapeRequest
Source§fn clone(&self) -> ScrapeRequest
fn clone(&self) -> ScrapeRequest
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more