From: Grégory Burri Date: Mon, 7 Sep 2020 13:39:41 +0000 (+0200) Subject: Create a client only once. X-Git-Url: http://git.euphorik.ch/index.cgi?a=commitdiff_plain;h=1bfe2373f1fbb8f58cbaa025706acedc4e2919a7;p=rtx3080.git Create a client only once. --- diff --git a/Cargo.lock b/Cargo.lock index 54963c8..a12ebec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -437,12 +437,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.8.2" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b62f79061a0bc2e046024cb7ba44b08419ed238ecbd9adbd787434b9e8c25" -dependencies = [ - "autocfg 1.0.1", -] +checksum = "00d63df3d41950fb462ed38308eea019113ad1508da725bbedcd0fa5a85ef5f7" [[package]] name = "hermit-abi" @@ -554,9 +551,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.5.2" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e47a3566dd4fd4eec714ae6ceabdee0caec795be835c223d92c2d40f1e8cf1c" +checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2" dependencies = [ "autocfg 1.0.1", "hashbrown", @@ -1451,9 +1448,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.39" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "891d8d6567fe7c7f8835a3a98af4208f3846fba258c1bc3c31d6e506239f11f9" +checksum = "963f7d3cc59b59b9325165add223142bbf1df27655d07789f109896d353d8350" dependencies = [ "proc-macro2", "quote", diff --git a/src/main.rs b/src/main.rs index 412d17c..9eca649 100644 --- a/src/main.rs +++ b/src/main.rs @@ -45,11 +45,13 @@ fn main() -> Result<(), Box> { }; let selector = Selector::parse("div.productGridElement > h2 > a:nth-child(1)").unwrap(); + let url = format!("https://www.steg-electronics.ch/fr/search?suche={}", to_find); + + let client = reqwest::blocking::Client::new(); loop { - let url = format!("https://www.steg-electronics.ch/fr/search?suche={}", to_find); println!("Request: {}", url); - let resp = reqwest::blocking::get(&url)?; + let resp = client.get(&url).send()?; if resp.status().is_success() { let html = resp.text()?;