test_google_html_fetch/
test_google_html_fetch.rs1use anyhow::Result;
2use headless_engine::network::client::NetworkClient;
3use headless_engine::network::fingerprint::DeviceProfile;
4
5#[tokio::main]
6async fn main() -> Result<()> {
7 let client = NetworkClient::with_profile(DeviceProfile::ChromeWindows)?;
8
9 let urls = [
10 "https://www.google.com/search?q=Rust+programming+language&udm=14&hl=en",
11 "https://www.google.com/search?q=Rust+programming+language&gbv=1&hl=en",
12 "https://www.google.com/search?q=Rust+programming+language&hl=en",
13 ];
14
15 for url in urls {
16 println!("--------------------------------------------------");
17 println!("Fetching: {}", url);
18 let res = client.fetch(url).await?;
19 println!("Status: {}", res.status);
20 println!("Bytes: {}", res.html.len());
21 println!(
22 "Contains search results container: {}",
23 res.html.contains("id=\"search\"")
24 || res.html.contains("class=\"g\"")
25 || res.html.contains("<h3")
26 || res.html.contains("id=\"rso\"")
27 );
28 println!(
29 "Contains fallback/sorry: {}",
30 res.html.contains("having trouble accessing") || res.html.contains("sorry/index")
31 );
32 }
33
34 Ok(())
35}