]> _ Git - local-tools.git/commitdiff
#7757 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 9 Dec 2025 13:55:09 +0000 (14:55 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 9 Dec 2025 13:55:09 +0000 (14:55 +0100)
app/Console/Commands/CFGroupURL.php
storage/app/private/http/cookies

index 8d753dad5b479bcc3ad39113cdf5eef5182cccd0..e5b4953afce348bb93ed5ef9394b4ad8bf356fe2 100644 (file)
@@ -21,7 +21,7 @@ class CFGroupURL extends Command
 
         $res = [];
         foreach ($refs as $ref) {
-            $res[$ref] = cache()->remember('cfgroup_ref_' . $ref, 1, function () use ($ref) {
+            $res[$ref] = cache()->remember('cfgroup_ref_' . $ref, 72000, function () use ($ref) {
                 $resp = HTTP::_request('https://www.my-cfgroup.fr/fr/recherche?display=produits&search=' . $ref, 30);
                 $body = $resp->getBody()->getContents();
                 $dom = new Dom();
@@ -29,10 +29,20 @@ class CFGroupURL extends Command
                 $products = $dom->find('h3.product-name a');
                 if (!count($products)) {
                     $res = '';
-                } else {
+                } else if (count($products) == 1) {
                     $res = $products[0]->getAttribute('href');
+                } else {
+                    foreach ($products as $product) {
+                        $url = $product->getAttribute('href');
+                        $e = explode('-', $url);
+                        if (in_array(mb_strtolower($ref), $e)) {
+                            $res = $url;
+                            break;
+                        }
+                    }
                 }
-                sleep(2);
+                usleep(1000000 * 0.25);
+                dump($ref, $res);
                 return $res;
             });
         }
index 5bd3959728b018d90779b1756a94e117883b5912..bf3219967986eed16703d81684704ea773250c99 100644 (file)
@@ -1 +1 @@
-[{"Name":"laravel_session","Value":"kamkVRx4urvPxP9R4tPMGXqcjyahKpZ72m9x8zVO","Domain":"www.my-cfgroup.fr","Path":"\/","Max-Age":null,"Expires":null,"Secure":true,"Discard":false,"HttpOnly":true},{"Name":"XSRF-TOKEN","Value":"eyJpdiI6InpVOVlRQW5uOXhwZDJCTk5cL0RSeDh3PT0iLCJ2YWx1ZSI6IitWY2tnSVcwejZKeDlPR2pYckNmekpEUEFvZzJXMWswTkNOeE1qU1MzUW1Mb0NpU2s1SW5kZzFzNW5JMVNoS24iLCJtYWMiOiIzYzY2NjFjZDNhYTFlMmQyNzYxOTdlY2JhMzQwOWI4MmY2MTUwYjFkYmViMWJmMjg4ZGZjZDg1Y2U1MWFlODI4In0%3D","Domain":"www.my-cfgroup.fr","Path":"\/","Max-Age":1800,"Expires":1765287552,"Secure":true,"Discard":false,"HttpOnly":false}]
\ No newline at end of file
+[{"Name":"laravel_session","Value":"kamkVRx4urvPxP9R4tPMGXqcjyahKpZ72m9x8zVO","Domain":"www.my-cfgroup.fr","Path":"\/","Max-Age":null,"Expires":null,"Secure":true,"Discard":false,"HttpOnly":true},{"Name":"XSRF-TOKEN","Value":"eyJpdiI6InpMYUdGalZIMlg0YXNyQWJIWFJiXC9BPT0iLCJ2YWx1ZSI6IkI5WXFxOHlVZmU4MVRwXC85SmVJVFBOWXN2NHNKM2pXWlMydTlVRitTTzdsekdKXC9QK0sybTJaMURoTXhsam5hTiIsIm1hYyI6IjJjOTFjZTU2MDM5ZTRjNWZhYjkxMWM4ZjcyOTlkYTkxNDNjNTUzYTg5MDY4ZWYyZGU3YzY5MmUyNDI4ZmU5YzgifQ%3D%3D","Domain":"www.my-cfgroup.fr","Path":"\/","Max-Age":1800,"Expires":1765290112,"Secure":true,"Discard":false,"HttpOnly":false}]
\ No newline at end of file