懂车帝移动端抓取
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\utils\crawl\service\UsedCarCrawlSingle;
|
||||
use app\common\validate\UsedCarValidate;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\UsedCar;
|
||||
@@ -421,4 +422,38 @@ class UsedCarService
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择车辆抓取方式
|
||||
* @param string $url
|
||||
*/
|
||||
public function selectCraw(string $url){
|
||||
$usedCarCrawl = new UsedCarCrawlSingle();
|
||||
switch (true){
|
||||
case str_contains($url,'dongchedi.com'): //懂车帝pc端
|
||||
$info = $usedCarCrawl->crawlCar($url);
|
||||
break;
|
||||
case str_contains($url,'dcdapp.com'): //懂车帝移动端
|
||||
$finalUrl = $usedCarCrawl->getPcUrl($url); //获取pc端页面链接
|
||||
if(empty($finalUrl)){
|
||||
throw new \Exception('链接解析错误');
|
||||
}
|
||||
$info = $usedCarCrawl->crawlCar($finalUrl);
|
||||
break;
|
||||
case str_contains($url,'t.zijieimg.com'): //懂车帝移动端分享链接
|
||||
$finalUrl = $usedCarCrawl->getFinaUrl($url); //解析抖音短链,并获取pc端页面链接
|
||||
if(empty($finalUrl)){
|
||||
throw new \Exception('链接解析错误');
|
||||
}
|
||||
$info = $usedCarCrawl->crawlCar($finalUrl);
|
||||
break;
|
||||
case str_contains($url,'che168.com'): //汽车之家
|
||||
throw new \Exception('加紧开发中');
|
||||
break;
|
||||
default:
|
||||
Log::info('未知链接:'.$url);
|
||||
throw new \Exception('加紧开发中');
|
||||
}
|
||||
return $info;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user