supervisor and other update
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use reqwest::{Client, Proxy};
|
||||
use reqwest::{header, Client, Proxy};
|
||||
use serde_json::json;
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize, Debug)]
|
||||
@@ -30,19 +30,36 @@ pub struct FlaresolverrCookie {
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize, Debug)]
|
||||
struct FlareSolverrSolution {
|
||||
pub struct FlareSolverrSolution {
|
||||
url: String,
|
||||
status: u32,
|
||||
response: String,
|
||||
pub response: String,
|
||||
headers: HashMap<String, String>,
|
||||
cookies: Vec<FlaresolverrCookie>,
|
||||
userAgent: String,
|
||||
}
|
||||
impl FlareSolverrSolution {
|
||||
fn to_client(&self,){
|
||||
let mut headers = header::HeaderMap::new();
|
||||
for (h, v) in &self.headers {
|
||||
println!("{}: {}", h, v);
|
||||
headers.insert(
|
||||
header::HeaderName::from_bytes(h.as_bytes()).unwrap(),
|
||||
header::HeaderValue::from_str(v).unwrap(),
|
||||
);
|
||||
}
|
||||
|
||||
// let client = reqwest::Client::builder()
|
||||
// .danger_accept_invalid_certs(true)
|
||||
// .
|
||||
// .build().unwrap();
|
||||
}
|
||||
}
|
||||
#[derive(serde::Serialize, serde::Deserialize, Debug)]
|
||||
struct FlareSolverrResponse {
|
||||
pub struct FlareSolverrResponse {
|
||||
status: String,
|
||||
message: String,
|
||||
solution: FlareSolverrSolution,
|
||||
pub solution: FlareSolverrSolution,
|
||||
startTimestamp: u64,
|
||||
endTimestamp: u64,
|
||||
version: String,
|
||||
@@ -60,7 +77,7 @@ impl Flaresolverr {
|
||||
pub async fn solve(
|
||||
&self,
|
||||
request: FlareSolverrRequest,
|
||||
) -> Result<String, Box<dyn std::error::Error>> {
|
||||
) -> Result<FlareSolverrResponse, Box<dyn std::error::Error>> {
|
||||
let client = Client::builder()
|
||||
.proxy(Proxy::https("http://192.168.0.101:8080").unwrap())
|
||||
.proxy(Proxy::http("http://192.168.0.101:8080").unwrap())
|
||||
@@ -78,7 +95,6 @@ impl Flaresolverr {
|
||||
.send().await?;
|
||||
|
||||
let body: FlareSolverrResponse = response.json::<FlareSolverrResponse>().await?;
|
||||
println!("FlareSolverr response: {:?}, {}", body.status, body.solution.response.len());
|
||||
Ok(body.solution.response)
|
||||
Ok(body)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user