作者 赵彬吉

update

@@ -54,13 +54,16 @@ class QuanqiusouApi @@ -54,13 +54,16 @@ class QuanqiusouApi
54 * @author zbj 54 * @author zbj
55 * @date 2023/5/11 55 * @date 2023/5/11
56 */ 56 */
57 - public function getSiteResPer($api_no){ 57 + public function getSiteResPer($api_no, $is_ext = 0, $copy_domain = ''){
58 // $key = 'quanqiusou_api_site_res_per_' . $api_no . '_' . date('Y-m-d'); 58 // $key = 'quanqiusou_api_site_res_per_' . $api_no . '_' . date('Y-m-d');
59 // $res = Cache::get($key); 59 // $res = Cache::get($key);
60 // if (!$res) { 60 // if (!$res) {
61 $api_url = $this->url . '/google-rank/echo_site_res_per.php'; 61 $api_url = $this->url . '/google-rank/echo_site_res_per.php';
62 try { 62 try {
63 - $res = HttpUtils::get($api_url, ['apino' => $api_no]); 63 + $param = ['apino' => $api_no];
  64 + $is_ext && $param['is_ext'] = $is_ext;
  65 + $copy_domain && $param['domain'] = $copy_domain;
  66 + $res = HttpUtils::get($api_url, $param);
64 if($res){ 67 if($res){
65 $res = Arr::s2a($res); 68 $res = Arr::s2a($res);
66 // Cache::put($key, $res, 2 * 3600); 69 // Cache::put($key, $res, 2 * 3600);
@@ -73,6 +76,26 @@ class QuanqiusouApi @@ -73,6 +76,26 @@ class QuanqiusouApi
73 return $res; 76 return $res;
74 } 77 }
75 78
  79 + /**
  80 + * 复制站点
  81 + * @return array|false|mixed
  82 + * @author zbj
  83 + * @date 2023/5/11
  84 + */
  85 + public function getSiteNumList(){
  86 + $api_url = $this->url . '/google-rank/ext_sitenum_list.php';
  87 + try {
  88 + $res = HttpUtils::get($api_url, []);
  89 + if($res){
  90 + $res = Arr::s2a($res);
  91 + }
  92 + } catch (\Exception | GuzzleException $e) {
  93 + errorLog('获取复制站点收录页面数', [], $e);
  94 + return [];
  95 + }
  96 + return array_column($res, 'url');
  97 + }
  98 +
76 99
77 /** 100 /**
78 * 获取谷歌排名数据 101 * 获取谷歌排名数据
@@ -28,6 +28,7 @@ use App\Models\RankData\Speed; @@ -28,6 +28,7 @@ use App\Models\RankData\Speed;
28 use App\Models\RankData\Speed as GoogleSpeedModel; 28 use App\Models\RankData\Speed as GoogleSpeedModel;
29 use App\Utils\HttpUtils; 29 use App\Utils\HttpUtils;
30 use GuzzleHttp\Exception\GuzzleException; 30 use GuzzleHttp\Exception\GuzzleException;
  31 +use Illuminate\Database\Eloquent\Model;
31 use Illuminate\Support\Collection; 32 use Illuminate\Support\Collection;
32 use Illuminate\Support\Facades\Cache; 33 use Illuminate\Support\Facades\Cache;
33 use Illuminate\Support\Facades\Log; 34 use Illuminate\Support\Facades\Log;
@@ -819,8 +820,19 @@ class RankDataLogic extends BaseLogic @@ -819,8 +820,19 @@ class RankDataLogic extends BaseLogic
819 if(!$model){ 820 if(!$model){
820 $model = new IndexedPagesModel(); 821 $model = new IndexedPagesModel();
821 } 822 }
  823 + $is_ext = 0;
  824 + $copy_domain = '';
822 $api = new QuanqiusouApi(); 825 $api = new QuanqiusouApi();
823 - $res = $api->getSiteResPer($api_no); 826 + //复制站 域名在这个http://api.quanqiusou.cn/google-rank/ext_sitenum_list.php里面 就用这个接口的数据
  827 + $domain = (new DomainInfo())->getDomain($domain);
  828 + $host = parse_url($domain, PHP_URL_HOST);
  829 + $host=str_replace('www.', '', $host);
  830 + $copy_site_list = $api->getSiteNumList();
  831 + if(in_array($host, $copy_site_list)){
  832 + $copy_domain = $host;
  833 + $is_ext = 1;
  834 + }
  835 + $res = $api->getSiteResPer($api_no, $is_ext, $copy_domain);
824 if(!$res){ 836 if(!$res){
825 Log::channel('rank_data')->error('syncIndexedPages:收录数数据为空', ['project_id' => $project_id, 'api_no' => $api_no]); 837 Log::channel('rank_data')->error('syncIndexedPages:收录数数据为空', ['project_id' => $project_id, 'api_no' => $api_no]);
826 continue; 838 continue;