From: Vincent Vanwaelscappel Date: Tue, 9 Dec 2025 13:55:09 +0000 (+0100) Subject: #7757 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=31b72e7bdde083fd384a80f0d6b674210ab9957d;p=local-tools.git #7757 @0.5 --- diff --git a/app/Console/Commands/CFGroupURL.php b/app/Console/Commands/CFGroupURL.php index 8d753da..e5b4953 100644 --- a/app/Console/Commands/CFGroupURL.php +++ b/app/Console/Commands/CFGroupURL.php @@ -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; }); } diff --git a/storage/app/private/http/cookies b/storage/app/private/http/cookies index 5bd3959..bf32199 100644 --- a/storage/app/private/http/cookies +++ b/storage/app/private/http/cookies @@ -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