Crates.io | fsolver |
lib.rs | fsolver |
version | 1.0.0 |
source | src |
created_at | 2024-11-28 08:49:05.357489 |
updated_at | 2024-11-28 08:49:05.357489 |
description | A simple wrapper around the FlareSolverr API |
homepage | |
repository | https://github.com/NandeMD/fsolver-rs |
max_upload_size | |
id | 1464049 |
size | 25,991 |
An easy to use, asynchronous wrapper for FlareSolverr.
# With default features (only `async`)
cargo add fsolver
# With all features (`async` and `blocking`)
cargo add fsolver -F all
# Only blocking
cargo add fsolver --no-default-features -F blocking
For more info, visit the documentation.
use fsolver::FlareSolverrAsync;
// Setup the flare solver instance with default settings
let solver = FlareSolverrAsync::new(None, None, None, None, None)
.await
.unwrap();
// With custom ip and port
let solver = FlareSolverrAsync::new(Some("127.0.0.1"), Some("5050"), None, None, None)
.await
.unwrap();
// Use different http schema
use fsolver::HttpSchema;
let solver = FlareSolverrAsync::new(None, None, Some(HttpSchema::Http), None, None)
.await
.unwrap();
// If you want some additional headers
use std::collections::HashMap;
let mut headers = HashMap::new();
headers.insert("User-Agent".to_string(), "Mozilla/5.0 (X11; Linux x86_64)".to_string());
let solver = FlareSolverrAsync::new(None, None, None, Some(headers), None)
.await
.unwrap();
// When (for whatever the reason) flaresolverr changes /v1 endpoint
let solver = FlareSolverrAsync::new(None, None, None, None, Some("v2"))
.await
.unwrap();
// List all sessions
let sessions: Vec<String> = solver.sessions().await.unwrap();
// List sessions and get response raw
let sessions: SessionListResponse = solver.sessions().await.unwrap();
// Create a new session with a random UUID
let session_id = solver.create_session(None).await.unwrap();
// Create a new session with a custom name/ID
let session_id = "myses";
let session_id = solver.create_session(Some(session_id)).await.unwrap();
// Delete/destroy a session
solver.destroy_session(session_id).await.unwrap();
// Get request
use fsolver::RequestGet;
let session_id = solverr.create_session(None).await.unwrap();
let get_request_params = RequestGet::new(
"https://example.com".into(),
Some(session_id),
None,
None,
None,
None,
None,
);
let response: GetPostRequestResponse = solver.request_get(get_request_params).await.unwrap()
// Post request
use fsolver::RequestPost;
let post_request_params = RequestPost::new_empty("https://example.com".to_string(), "a=b&c=d".to_string())
let response: GetPostRequestResponse = solver.request_post(post_request_params).await.unwrap();
use fsolver::FlareSolverrBlocking;
// Yep, just that. All functions are the same. Call functions without await.