抓取确认

This commit is contained in:
2026-03-12 14:21:12 +08:00
parent 3c948fbb9b
commit 7c7e66ae9a
3 changed files with 68 additions and 6 deletions
+32 -1
View File
@@ -880,7 +880,7 @@ class UsedCarDetailService
* @return array 返回创建的车辆数据
* @throws \Exception
*/
public function crawlAndStore(string $url, int $userId): array
public function crawl(string $url, int $userId): array
{
// 检查该用户是否已抓取过此URL的车辆
$existingCar = UsedCarDetail::where('user_id', $userId)
@@ -946,7 +946,38 @@ class UsedCarDetailService
return !is_array($value);
});
$data = array_merge($data, $params);
return $data;
// 5. 创建记录
/*$car = UsedCarDetail::create($data);
// 6. 将推送任务发送到队列
try {
\Webman\RedisQueue\Redis::send('wordpress-push', [
'car_id' => $car->id,
]);
Log::info('WordPress推送任务已加入队列', ['car_id' => $car->id]);
} catch (\Throwable $e) {
Log::error('WordPress推送任务加入队列失败', [
'car_id' => $car->id,
'error' => $e->getMessage(),
]);
}
return $car->toArray();*/
}
/**
* 保存懂车帝二手车数据
*
* @param string $url 懂车帝二手车链接
* @param int $userId 用户ID
* @return array 返回创建的车辆数据
* @throws \Exception
*/
public function crawlStore(array $data, int $userId): array
{
$data['user_id'] = $userId;
// 5. 创建记录
$car = UsedCarDetail::create($data);