|
...
|
...
|
@@ -3,6 +3,7 @@ |
|
|
|
namespace App\Http\Controllers\Bside;
|
|
|
|
|
|
|
|
|
|
|
|
use App\Helper\Arr;
|
|
|
|
use App\Helper\GoogleSpeedApi;
|
|
|
|
use App\Helper\QuanqiusouApi;
|
|
|
|
use App\Http\Logic\Aside\Project\ProjectLogic;
|
|
...
|
...
|
@@ -10,6 +11,9 @@ use App\Http\Logic\Bside\RankDataLogic; |
|
|
|
use App\Models\RankData\RankData;
|
|
|
|
use App\Models\RankData\Speed as GoogleSpeedModel;
|
|
|
|
use App\Services\BatchExportService;
|
|
|
|
use App\Utils\HttpUtils;
|
|
|
|
use GuzzleHttp\Client;
|
|
|
|
use GuzzleHttp\Promise\Utils;
|
|
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -162,4 +166,56 @@ class RankDataController extends BaseController |
|
|
|
// return Storage::disk('runtime')->download($file); //直接下载
|
|
|
|
return $this->success(['url' => $fileurl]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 实时获取关键词排名
|
|
|
|
* @author zbj
|
|
|
|
* @date 2023/5/16
|
|
|
|
*/
|
|
|
|
public function get_google_rank(){
|
|
|
|
$url_arr = parse_url($this->request['url']);
|
|
|
|
$param = [
|
|
|
|
'keyword' => trim($this->request['keyword']),
|
|
|
|
'url' => $url_arr['host'] ?? $url_arr['path'],
|
|
|
|
'extend_urls' => $this->request['extend_urls'],
|
|
|
|
'lang' => $this->request['lang'],
|
|
|
|
'use_groups' => 2
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
if ($this->request['w']) {
|
|
|
|
$data = [
|
|
|
|
'position' => 0,
|
|
|
|
'image_position' => 0,
|
|
|
|
'video_position' => 0,
|
|
|
|
];
|
|
|
|
$client = new Client([
|
|
|
|
'base_uri' => 'http://45.136.131.71:8000',
|
|
|
|
'timeout' => '20'
|
|
|
|
]);
|
|
|
|
|
|
|
|
$promises['position'] = $client->getAsync('/luminati_rank?'.Arr::query($param));
|
|
|
|
$promises['image_position'] = $client->getAsync('/google_image?'.Arr::query($param));
|
|
|
|
$promises['video_position'] = $client->getAsync('/google_video?'.Arr::query($param));
|
|
|
|
|
|
|
|
// 等待所有请求响应完成
|
|
|
|
$results = Utils:: settle($promises)->wait();
|
|
|
|
foreach ($results as $key => $result) {
|
|
|
|
if ($result['state'] == 'fulfilled') {
|
|
|
|
$res = Arr::s2a($result['value']->getBody()->getContents());
|
|
|
|
$data[$key] = $res['position'] ?? 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
$data = [
|
|
|
|
'position' => 0,
|
|
|
|
];
|
|
|
|
$res = HttpUtils::get('http://45.136.131.71:8000/luminati_rank', $param);
|
|
|
|
if ($res) {
|
|
|
|
$res = Arr::s2a($res);
|
|
|
|
$data['position'] = $res['position'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|