use reqwest::header::{HeaderMap, HeaderValue};
use reqwest_cookie_store::CookieStoreMutex;
use std::sync::Arc;
pub const TREEHOLE_BASE: &str = "https://treehole.pku.edu.cn";
pub fn build(cookie_store: Arc<CookieStoreMutex>) -> anyhow::Result<reqwest::Client> {
let mut headers = HeaderMap::new();
headers.insert(
"accept",
HeaderValue::from_static("application/json, text/plain, */*"),
);
headers.insert(
"user-agent",
HeaderValue::from_static(
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36",
),
);
let client = reqwest::Client::builder()
.cookie_provider(cookie_store)
.default_headers(headers)
.redirect(reqwest::redirect::Policy::none()) .build()?;
Ok(client)
}
pub fn build_simple() -> anyhow::Result<reqwest::Client> {
let mut headers = HeaderMap::new();
headers.insert(
"user-agent",
HeaderValue::from_static(
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36",
),
);
let client = reqwest::Client::builder()
.cookie_store(true)
.default_headers(headers)
.build()?;
Ok(client)
}