Create a client only once.
authorGrégory Burri <gregory.burri@matisa.ch>
Mon, 7 Sep 2020 13:39:41 +0000 (15:39 +0200)
committerGrégory Burri <gregory.burri@matisa.ch>
Mon, 7 Sep 2020 13:39:41 +0000 (15:39 +0200)
Cargo.lock
src/main.rs

index 54963c8..a12ebec 100644 (file)
@@ -437,12 +437,9 @@ dependencies = [
 
 [[package]]
 name = "hashbrown"
 
 [[package]]
 name = "hashbrown"
-version = "0.8.2"
+version = "0.9.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e91b62f79061a0bc2e046024cb7ba44b08419ed238ecbd9adbd787434b9e8c25"
-dependencies = [
- "autocfg 1.0.1",
-]
+checksum = "00d63df3d41950fb462ed38308eea019113ad1508da725bbedcd0fa5a85ef5f7"
 
 [[package]]
 name = "hermit-abi"
 
 [[package]]
 name = "hermit-abi"
@@ -554,9 +551,9 @@ dependencies = [
 
 [[package]]
 name = "indexmap"
 
 [[package]]
 name = "indexmap"
-version = "1.5.2"
+version = "1.6.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4e47a3566dd4fd4eec714ae6ceabdee0caec795be835c223d92c2d40f1e8cf1c"
+checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2"
 dependencies = [
  "autocfg 1.0.1",
  "hashbrown",
 dependencies = [
  "autocfg 1.0.1",
  "hashbrown",
@@ -1451,9 +1448,9 @@ dependencies = [
 
 [[package]]
 name = "syn"
 
 [[package]]
 name = "syn"
-version = "1.0.39"
+version = "1.0.40"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "891d8d6567fe7c7f8835a3a98af4208f3846fba258c1bc3c31d6e506239f11f9"
+checksum = "963f7d3cc59b59b9325165add223142bbf1df27655d07789f109896d353d8350"
 dependencies = [
  "proc-macro2",
  "quote",
 dependencies = [
  "proc-macro2",
  "quote",
index 412d17c..9eca649 100644 (file)
@@ -45,11 +45,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
         };
 
     let selector = Selector::parse("div.productGridElement > h2 > a:nth-child(1)").unwrap();
         };
 
     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 {
 
     loop {
-        let url = format!("https://www.steg-electronics.ch/fr/search?suche={}", to_find);
         println!("Request: {}", url);
         println!("Request: {}", url);
-        let resp = reqwest::blocking::get(&url)?;
+        let resp = client.get(&url).send()?;
 
         if resp.status().is_success() {
             let html = resp.text()?;
 
         if resp.status().is_success() {
             let html = resp.text()?;