pub struct Spider {
pub api_key: String,
pub client: Client,
}Expand description
Represents a Spider with API key and HTTP client.
Fields§
§api_key: StringThe Spider API key.
client: ClientThe Spider Client to re-use.
Implementations§
Source§impl Spider
impl Spider
Sourcepub fn new_with_client(
api_key: Option<String>,
client: Client,
) -> Result<Self, &'static str>
pub fn new_with_client( api_key: Option<String>, client: Client, ) -> Result<Self, &'static str>
Sourcepub async fn api_post(
&self,
endpoint: &str,
data: impl Serialize + Debug + Clone + Send + Sync,
content_type: &str,
) -> Result<Response, Error>
pub async fn api_post( &self, endpoint: &str, data: impl Serialize + Debug + Clone + Send + Sync, content_type: &str, ) -> Result<Response, Error>
Sourcepub async fn api_get<T: Serialize>(
&self,
endpoint: &str,
query_params: Option<&T>,
) -> Result<Value, Error>
pub async fn api_get<T: Serialize>( &self, endpoint: &str, query_params: Option<&T>, ) -> Result<Value, Error>
Sourcepub async fn api_delete(
&self,
endpoint: &str,
params: Option<HashMap<String, Value>>,
) -> Result<Response, Error>
pub async fn api_delete( &self, endpoint: &str, params: Option<HashMap<String, Value>>, ) -> Result<Response, Error>
Sourcepub async fn scrape_url(
&self,
url: &str,
params: Option<RequestParams>,
content_type: &str,
) -> Result<Value, Error>
pub async fn scrape_url( &self, url: &str, params: Option<RequestParams>, content_type: &str, ) -> Result<Value, Error>
Sourcepub async fn multi_scrape_url(
&self,
params: Option<Vec<RequestParams>>,
content_type: &str,
) -> Result<Value, Error>
pub async fn multi_scrape_url( &self, params: Option<Vec<RequestParams>>, content_type: &str, ) -> Result<Value, Error>
Sourcepub async fn crawl_url(
&self,
url: &str,
params: Option<RequestParams>,
stream: bool,
content_type: &str,
callback: Option<impl Fn(Value) + Send>,
) -> Result<Value, Error>
pub async fn crawl_url( &self, url: &str, params: Option<RequestParams>, stream: bool, content_type: &str, callback: Option<impl Fn(Value) + Send>, ) -> Result<Value, Error>
Sourcepub async fn multi_crawl_url(
&self,
params: Option<Vec<RequestParams>>,
stream: bool,
content_type: &str,
callback: Option<impl Fn(Value) + Send>,
) -> Result<Value, Error>
pub async fn multi_crawl_url( &self, params: Option<Vec<RequestParams>>, stream: bool, content_type: &str, callback: Option<impl Fn(Value) + Send>, ) -> Result<Value, Error>
Crawls multiple URLs.
§Arguments
url- The URL to crawl.params- Optional request parameters.stream- Whether streaming is enabled.content_type- The content type of the request.callback- Optional callback function to handle each streamed chunk.
§Returns
The response from the API as a JSON value.
Sourcepub async fn links(
&self,
url: &str,
params: Option<RequestParams>,
_stream: bool,
content_type: &str,
) -> Result<Value, Error>
pub async fn links( &self, url: &str, params: Option<RequestParams>, _stream: bool, content_type: &str, ) -> Result<Value, Error>
Sourcepub async fn multi_links(
&self,
params: Option<Vec<RequestParams>>,
_stream: bool,
content_type: &str,
) -> Result<Value, Error>
pub async fn multi_links( &self, params: Option<Vec<RequestParams>>, _stream: bool, content_type: &str, ) -> Result<Value, Error>
Sourcepub async fn screenshot(
&self,
url: &str,
params: Option<RequestParams>,
_stream: bool,
content_type: &str,
) -> Result<Value, Error>
pub async fn screenshot( &self, url: &str, params: Option<RequestParams>, _stream: bool, content_type: &str, ) -> Result<Value, Error>
Sourcepub async fn multi_screenshot(
&self,
params: Option<Vec<RequestParams>>,
_stream: bool,
content_type: &str,
) -> Result<Value, Error>
pub async fn multi_screenshot( &self, params: Option<Vec<RequestParams>>, _stream: bool, content_type: &str, ) -> Result<Value, Error>
Sourcepub async fn search(
&self,
q: &str,
params: Option<SearchRequestParams>,
_stream: bool,
content_type: &str,
) -> Result<Value, Error>
pub async fn search( &self, q: &str, params: Option<SearchRequestParams>, _stream: bool, content_type: &str, ) -> Result<Value, Error>
Sourcepub async fn multi_search(
&self,
params: Option<Vec<SearchRequestParams>>,
content_type: &str,
) -> Result<Value, Error>
pub async fn multi_search( &self, params: Option<Vec<SearchRequestParams>>, content_type: &str, ) -> Result<Value, Error>
Sourcepub async fn transform(
&self,
data: Vec<HashMap<&str, &str>>,
params: Option<TransformParams>,
_stream: bool,
content_type: &str,
) -> Result<Value, Error>
pub async fn transform( &self, data: Vec<HashMap<&str, &str>>, params: Option<TransformParams>, _stream: bool, content_type: &str, ) -> Result<Value, Error>
Sourcepub async fn download(
&self,
url: Option<&str>,
options: Option<HashMap<&str, i32>>,
) -> Result<Response, Error>
pub async fn download( &self, url: Option<&str>, options: Option<HashMap<&str, i32>>, ) -> Result<Response, Error>
Sourcepub async fn create_signed_url(
&self,
url: Option<&str>,
options: Option<HashMap<&str, i32>>,
) -> Result<Value, Error>
pub async fn create_signed_url( &self, url: Option<&str>, options: Option<HashMap<&str, i32>>, ) -> Result<Value, Error>
Sourcepub async fn get_crawl_state(
&self,
url: &str,
params: Option<RequestParams>,
content_type: &str,
) -> Result<Value, Error>
pub async fn get_crawl_state( &self, url: &str, params: Option<RequestParams>, content_type: &str, ) -> Result<Value, Error>
Sourcepub async fn get_credits(&self) -> Result<Value, Error>
pub async fn get_credits(&self) -> Result<Value, Error>
Get the account credits left.
Sourcepub async fn data_post(
&self,
table: &str,
data: Option<RequestParams>,
) -> Result<Value, Error>
pub async fn data_post( &self, table: &str, data: Option<RequestParams>, ) -> Result<Value, Error>
Send a request for a data record.
Sourcepub async fn query(&self, params: &QueryRequest) -> Result<Value, Error>
pub async fn query(&self, params: &QueryRequest) -> Result<Value, Error>
Query a record from the global DB.
Sourcepub async fn data_get(
&self,
table: &str,
params: Option<RequestParams>,
) -> Result<Value, Error>
pub async fn data_get( &self, table: &str, params: Option<RequestParams>, ) -> Result<Value, Error>
Get a table record.
Sourcepub async fn data_delete(
&self,
table: &str,
params: Option<RequestParams>,
) -> Result<Value, Error>
pub async fn data_delete( &self, table: &str, params: Option<RequestParams>, ) -> Result<Value, Error>
Delete a record.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Spider
impl !RefUnwindSafe for Spider
impl Send for Spider
impl Sync for Spider
impl Unpin for Spider
impl !UnwindSafe for Spider
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
Mutably borrows from an owned value. Read more