|
...
|
...
|
@@ -9,6 +9,8 @@ |
|
|
|
|
|
|
|
namespace App\Services;
|
|
|
|
|
|
|
|
use App\Helper\Country;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :google关键字扩展
|
|
|
|
* @name :GoogleSearchService
|
|
...
|
...
|
@@ -21,7 +23,7 @@ class GoogleSearchService |
|
|
|
public $url = "";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :请求数据
|
|
|
|
* @remark :扩展关键词请求数据
|
|
|
|
* @name :requestUrl
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
...
|
...
|
@@ -30,6 +32,30 @@ class GoogleSearchService |
|
|
|
public function requestUrl($keyword){
|
|
|
|
$this->url = 'https://google-keyword-insight1.p.rapidapi.com/globalkey';
|
|
|
|
$url = $this->url.'/?keyword='.$keyword.'&lang=en';
|
|
|
|
return $this->curlGoogleApi($url);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :热门关键词拉取
|
|
|
|
* @name :requestKeywordUrl
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/3/27 16:57
|
|
|
|
*/
|
|
|
|
public function requestKeywordUrl($keyword){
|
|
|
|
$this->url = 'https://google-keyword-insight1.p.rapidapi.com/topkeys';
|
|
|
|
$url = $this->url.'/?keyword='.$keyword.'&location=US&&lang=en';
|
|
|
|
return $this->curlGoogleApi($url);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :请求
|
|
|
|
* @name :curlGoogleApi
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/3/27 16:59
|
|
|
|
*/
|
|
|
|
public function curlGoogleApi($url){
|
|
|
|
$curl = curl_init();
|
|
|
|
curl_setopt_array($curl, [
|
|
|
|
CURLOPT_URL => $url,
|
|
...
|
...
|
@@ -48,7 +74,7 @@ class GoogleSearchService |
|
|
|
$err = curl_error($curl);
|
|
|
|
curl_close($curl);
|
|
|
|
if ($err) {
|
|
|
|
errorLog("关键词扩展cURL Error #:", $url, $err);
|
|
|
|
errorLog("热门关键词cURL Error #:", $url, $err);
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return json_decode($response,true);
|
|
...
|
...
|
@@ -61,12 +87,27 @@ class GoogleSearchService |
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/3/27 11:18
|
|
|
|
* @param :date,query,page,device,country
|
|
|
|
* @param :date,query,page,device,country/时间、聚合、前页、设备、国家
|
|
|
|
*/
|
|
|
|
public function googleSearch($data){
|
|
|
|
$this->url = 'https://www.cmer.site/api/google/search?domain=www.suertetextile.com&q=';
|
|
|
|
$url = $this->url.$data;
|
|
|
|
return http_get($url);
|
|
|
|
public function googleSearch($domain,$search){
|
|
|
|
$data = [
|
|
|
|
1=>'date',
|
|
|
|
2=>'query',
|
|
|
|
3=>'page',
|
|
|
|
4=>'device',
|
|
|
|
5=>'country'
|
|
|
|
];
|
|
|
|
$this->url = 'https://www.cmer.site/api/google/search';
|
|
|
|
$url = $this->url.'?domain='.$domain.'&q='.$data[$search];
|
|
|
|
$data = http_get($url);
|
|
|
|
$data = $data['data'] ?? [];
|
|
|
|
if(!empty($data) && ($search == 5)){
|
|
|
|
foreach ($data as $key => $val){
|
|
|
|
$val['keys_country'] = Country::getCountryNameByAlpha3(strtoupper($val['keys'][0]));
|
|
|
|
$data[$key] = $val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
} |
...
|
...
|
|