抓取车辆
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\model\UsedCar;
|
||||
use app\common\model\UsedCarPdfLog;
|
||||
use app\common\model\User;
|
||||
@@ -9,8 +8,8 @@ use app\common\service\OssService;
|
||||
use app\common\service\SparkService;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\UsedCarService;
|
||||
use app\common\utils\crawl\service\UsedCarCrawlSingle;
|
||||
use app\common\utils\pdf\service\MpdfDriver;
|
||||
use app\queue\utils\XunfeiFanyi;
|
||||
use support\exception\BusinessException;
|
||||
use support\Request;
|
||||
|
||||
@@ -127,6 +126,41 @@ class UsedCarController extends BaseController
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function crawlCar(Request $request)
|
||||
{
|
||||
try {
|
||||
$url = $request->get('url');
|
||||
if (empty($url)){
|
||||
throw new BusinessException('url不能为空');
|
||||
}
|
||||
$info = (new UsedCarCrawlSingle())->crawlCar($url);
|
||||
$data = [
|
||||
'user_id' => $request->user['id'],
|
||||
'product_name' => $info['title'],
|
||||
'price' => $info['price']<200 ? $info['price']*10000 : $info['price'],
|
||||
'source_place' => $info['source_place'],
|
||||
'displacement' => $info['capacity'], //排量
|
||||
'mileage' => $info['usage_mileage']*10000, //里程
|
||||
'power' => $info['horsepower'], //马力
|
||||
'body_color' => $info['body_color'],
|
||||
'images' => $info['image'],
|
||||
'image_pull' => $info['image_pull'],
|
||||
'condition_desc' => $info['condition_desc'],
|
||||
'attachment' => '',
|
||||
'source_url' => $url,
|
||||
'crawl_car_id' => $info['car_id'],
|
||||
'crawl_brand_id' => $info['brand_id'],
|
||||
'crawl_series_id' => $info['series_id'],
|
||||
'used_car_id' => $info['used_car_id'],
|
||||
];
|
||||
|
||||
|
||||
return $this->success($data);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage().'|'.$e->getLine().$e->getFile().$e->getTraceAsString());
|
||||
}
|
||||
}
|
||||
|
||||
public function crawlKeyword(Request $request){
|
||||
try {
|
||||
// $keyword = $request->get('keyword');
|
||||
|
||||
Reference in New Issue
Block a user