Install
Rust with Cargo. The examples use reqwest's async client on Tokio. Add --features socks to the first line only if you connect over SOCKS5.
cargo add reqwest
cargo add tokio --features fullRotating residential
pool_max_idle_per_host(0) keeps no idle connections, so every request opens a new tunnel through the residential gateway and leaves from a new address. A new Client per request rotates too, but rebuilds its TLS setup each time; one client with no idle pool is cheaper.
use std::time::Duration;
#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
let client = reqwest::Client::builder()
.proxy(reqwest::Proxy::all("http://USER:[email protected]:8000")?)
.pool_max_idle_per_host(0)
.timeout(Duration::from_secs(30))
.build()?;
for _ in 0..3 {
let body = client.get("https://httpbin.org/ip").send().await?.text().await?;
println!("{}", body.trim());
}
Ok(())
}A static datacenter or ISP IP
On a static datacenter IP keep the pool, so requests reuse connections. .basic_auth takes the username and password as plain strings, so nothing needs escaping in a URL. For an ISP order, use the host and port your dashboard lists for it.
use std::time::Duration;
#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
let proxy = reqwest::Proxy::all("http://IP:PORT")?.basic_auth("USER", "PASS");
let client = reqwest::Client::builder()
.proxy(proxy)
.connect_timeout(Duration::from_secs(10))
.timeout(Duration::from_secs(30))
.build()?;
for url in ["https://httpbin.org/ip", "https://httpbin.org/headers"] {
let resp = client.get(url).send().await?;
let status = resp.status();
let body = resp.text().await?;
println!("{status} {}", body.len());
}
Ok(())
}Keeping one identity
A Client keeps idle connections per host, and through the proxy each one is a tunnel with one exit address. Keep the default pool and requests to one site reuse those tunnels and their addresses until the connections idle out, which suits a short multi-step flow and surprises you when you expected rotation. reqwest keeps no cookies unless you enable its cookies feature and call .cookie_store(true). For an address that holds across new connections, use a static IP or a residential sticky session; the session setting for your account is in the dashboard.