--- /dev/null
+<?php
+
+namespace App\Console\Commands;
+
+use Cubist\Net\HTTP;
+use Cubist\Util\Files\Files;
+use Cubist\Util\Str;
+use Cubist\Util\Text;
+use Illuminate\Console\Command;
+use PHPHtmlParser\Dom;
+
+class CFGroupURL extends Command
+{
+ protected $signature = 'fluidbook:cfgroup:url';
+
+ public function handle()
+ {
+ $refs = $this->getAllReferences();
+
+ HTTP::setCookieFile(Files::mkdir(storage_path('app/private/http')) . 'cookies');
+
+ $res = [];
+ foreach ($refs as $ref) {
+ $res[$ref] = cache()->remember('cfgroup_ref_' . $ref, 1, 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();
+ $dom->loadStr($body);
+ $products = $dom->find('h3.product-name a');
+ if (!count($products)) {
+ $res = '';
+ } else {
+ $res = $products[0]->getAttribute('href');
+ }
+ sleep(2);
+ return $res;
+ });
+ }
+ dd($res);
+ return $res;
+ }
+
+ public function getAllReferences()
+ {
+ $res = [];
+ foreach (Text::explodeNewLines(file_get_contents(storage_path('app/private/fluidbook/cfgroup/urls.csv'))) as $line) {
+ if (!isset($first)) {
+ $first = true;
+ continue;
+ }
+ $e = explode(';', $line);
+ $res[] = trim($e[0]);
+ }
+ return $res;
+ }
+}
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "f64e35c6d4ebc997b1e69a89a3d4fd4b",
+ "content-hash": "1002e053aa9e24d9460791f8a80b0e3b",
"packages": [
{
"name": "aws/aws-crt-php",
],
"time": "2025-11-20T02:34:59+00:00"
},
+ {
+ "name": "paquettg/php-html-parser",
+ "version": "2.2.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/paquettg/php-html-parser.git",
+ "reference": "668c770fc5724ea3f15b8791435f054835be8d5e"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/paquettg/php-html-parser/zipball/668c770fc5724ea3f15b8791435f054835be8d5e",
+ "reference": "668c770fc5724ea3f15b8791435f054835be8d5e",
+ "shasum": ""
+ },
+ "require": {
+ "ext-curl": "*",
+ "ext-mbstring": "*",
+ "ext-zlib": "*",
+ "paquettg/string-encode": "~1.0.0",
+ "php": ">=7.1"
+ },
+ "require-dev": {
+ "infection/infection": "^0.13.4",
+ "mockery/mockery": "^1.2",
+ "phan/phan": "^2.4",
+ "php-coveralls/php-coveralls": "^2.1",
+ "phpunit/phpunit": "^7.5.1"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "PHPHtmlParser\\": "src/PHPHtmlParser"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Gilles Paquette",
+ "email": "paquettg@gmail.com",
+ "homepage": "http://gillespaquette.ca"
+ }
+ ],
+ "description": "An HTML DOM parser. It allows you to manipulate HTML. Find tags on an HTML page with selectors just like jQuery.",
+ "homepage": "https://github.com/paquettg/php-html-parser",
+ "keywords": [
+ "dom",
+ "html",
+ "parser"
+ ],
+ "support": {
+ "issues": "https://github.com/paquettg/php-html-parser/issues",
+ "source": "https://github.com/paquettg/php-html-parser/tree/2.2.1"
+ },
+ "time": "2020-01-20T12:59:15+00:00"
+ },
+ {
+ "name": "paquettg/string-encode",
+ "version": "1.0.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/paquettg/string-encoder.git",
+ "reference": "a8708e9fac9d5ddfc8fc2aac6004e2cd05d80fee"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/paquettg/string-encoder/zipball/a8708e9fac9d5ddfc8fc2aac6004e2cd05d80fee",
+ "reference": "a8708e9fac9d5ddfc8fc2aac6004e2cd05d80fee",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.1"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^7.5.1"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-0": {
+ "stringEncode": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Gilles Paquette",
+ "email": "paquettg@gmail.com",
+ "homepage": "http://gillespaquette.ca"
+ }
+ ],
+ "description": "Facilitating the process of altering string encoding in PHP.",
+ "homepage": "https://github.com/paquettg/string-encoder",
+ "keywords": [
+ "charset",
+ "encoding",
+ "string"
+ ],
+ "support": {
+ "issues": "https://github.com/paquettg/string-encoder/issues",
+ "source": "https://github.com/paquettg/string-encoder/tree/1.0.1"
+ },
+ "time": "2018-12-21T02:25:09+00:00"
+ },
{
"name": "phpoption/phpoption",
"version": "1.9.4",
"platform": {
"php": "^8.2"
},
- "platform-dev": {},
+ "platform-dev": [],
"plugin-api-version": "2.6.0"
}