logger = $loggerFactory->get('log', 'command'); } public function configure() { parent::configure(); $this->setDescription('Hyperf Demo Command'); } public function handle() { $this->line('Hello Hyperf!', 'info'); // Crawler::create([ // RequestOptions::TIMEOUT => 30.0, // 请求最大持续时间 // RequestOptions::CONNECT_TIMEOUT => 10.0, // 连接超时 // ])->setCrawlObserver(new TestClass())->startCrawling('https://theimpression.com/milan-street-style-fall-2025-day-6/'); $query = AppArticle::where('id', '>', 1); // $model = new ReviewModel(); $map = [ // 'Fall 1996 Ready-to-Wear' => '/Fall ([0-9]*?) Ready-to-Wear/', '/Fall ([0-9]*?) Ready-to-Wear/' => [ 'trans' => '秋季成衣', 'style' => 0, 'location' => 0, ], '/Spring ([0-9]*?) Ready-to-Wear/' => [ 'trans' => '春季成衣', 'style' => 0, 'location' => 0, ], '/Pre-Fall ([0-9]*?)/' => [ 'trans' => '早秋', 'style' => 0, 'location' => 0, ], '/Australia Resort ([0-9]*?)/' => [ 'trans' => '时装', 'style' => 1, 'location' => 1, ], '/Fall ([0-9]*?) Menswear/' => [ 'trans' => '秋季男装', 'style' => 0, 'location' => 1, // 澳大利亚 ], '/Ukraine Fall ([0-9]*?)/' => [ 'trans' => '秋季', 'style' => 0, 'location' => 2, // 乌克兰 ], '/Kiev Fall ([0-9]*?)/' => [ 'trans' => '秋季', 'style' => 0, 'location' => 3, // 基辅 ], '/Stockholm Fall ([0-9]*?)/' => [ 'trans' => '秋季', 'style' => 0, 'location' => 4, // 斯德哥尔摩 ], '/Tokyo Fall ([0-9]*?)/' => [ 'trans' => '秋季', 'style' => 0, 'location' => 5, // 东京 ], '/Berlin Fall ([0-9]*?)/' => [ 'trans' => '秋季', 'style' => 0, 'location' => 6, // 柏林 ], '/Copenhagen Fall ([0-9]*?)/' => [ 'trans' => '秋季', 'style' => 0, 'location' => 7, // 哥本哈根 ], '/([0-9]*?) Spring Summer/' => [ 'trans' => '春夏', 'style' => 0, 'location' => 0, ], '/([0-9]*?) Autumn Winter/' => [ 'trans' => '秋冬', 'style' => 0, 'location' => 0, ], ]; // // var_dump(TitleHelper::translate('Pre-Fall 2019'));die; foreach ($query->cursor() as $item) { echo '正在同步' . $item->id . PHP_EOL; if (in_array($item->title, ['春季', ' 春季', '秋季', ' 秋季', '早秋', ' 早秋', '时装', ' 时装']) || stripos($item->title, '|') !== false) { $originTitle = AppSpiderArticle::find($item->spider_article_id)->title; if ($title = TitleHelper::translate($originTitle)) { var_dump($title); $item->title = $title; $item->save(); } } else { if ($title = TitleHelper::translate($item->title)) { $item->title = $title; $item->save(); } } // $model = AppArticle::find($item->id); // $model->aid = strtr(uniqid(more_entropy:true), [ // '.' => '' // ]); //// $model->description = '1'; // $model->save(); // foreach ($map as $mapPreg => $mapItem) { // // preg_match_all($mapPreg, $item->title, $matches); // // if (count($matches) > 1 && $matches[1]) { // echo current($matches[1]) . " {$mapItem['trans']}" . PHP_EOL; // $model = AppArticle::find($item->id); // $model->title = current($matches[1]) . " {$mapItem['trans']}"; // $model->location = $mapItem['location']; // $model->style = $mapItem['style']; // // echo 'save'; // $model->save(); // continue; // } } // //// $model->pass($item->id); //// ////// var_dump($item->created_at->date); ////// $model->deleted_at = $item->created_at->timestamp; ////// var_dump($model->save()); // } // Fall 1996 Ready-to-Wear // Spring 2025 Ready-to-Wear // Pre-Fall 2025 } }