作者 刘锟

Merge remote-tracking branch 'origin/master' into akun

... ... @@ -57,7 +57,7 @@ class AiBlogTask extends Command
$aiBlogService->key = $aiSettingInfo['key'];
$aiBlogService->task_id = $item['task_id'];
$result = $aiBlogService->getDetail();
if($result['status'] != 200){
if(!isset($result['status']) || $result['status'] != 200){
sleep(5);
continue;
}
... ...
... ... @@ -54,13 +54,16 @@ class QuanqiusouApi
* @author zbj
* @date 2023/5/11
*/
public function getSiteResPer($api_no){
public function getSiteResPer($api_no, $is_ext = 0, $copy_domain = ''){
// $key = 'quanqiusou_api_site_res_per_' . $api_no . '_' . date('Y-m-d');
// $res = Cache::get($key);
// if (!$res) {
$api_url = $this->url . '/google-rank/echo_site_res_per.php';
try {
$res = HttpUtils::get($api_url, ['apino' => $api_no]);
$param = ['apino' => $api_no];
$is_ext && $param['is_ext'] = $is_ext;
$copy_domain && $param['domain'] = $copy_domain;
$res = HttpUtils::get($api_url, $param);
if($res){
$res = Arr::s2a($res);
// Cache::put($key, $res, 2 * 3600);
... ... @@ -73,6 +76,26 @@ class QuanqiusouApi
return $res;
}
/**
* 复制站点
* @return array|false|mixed
* @author zbj
* @date 2023/5/11
*/
public function getSiteNumList(){
$api_url = $this->url . '/google-rank/ext_sitenum_list.php';
try {
$res = HttpUtils::get($api_url, []);
if($res){
$res = Arr::s2a($res);
}
} catch (\Exception | GuzzleException $e) {
errorLog('获取复制站点收录页面数', [], $e);
return [];
}
return array_column($res, 'url');
}
/**
* 获取谷歌排名数据
... ...
... ... @@ -54,6 +54,7 @@ class KeywordLogic extends BaseLogic
* @author :lyh
* @method :post
* @time :2023/8/23 16:50
* @param :is_video_keyword:1->生成视频的关键字
*/
public function keywordSave(){
$this->param = $this->handleSaveParam($this->param);
... ... @@ -146,16 +147,12 @@ class KeywordLogic extends BaseLogic
* @time :2024/10/28 10:47
*/
public function first_word($title){
$first_title = mb_substr($title, 0, 1);
//返回对应的键
$keywordModel = new Keyword();
$firstNumWord = $keywordModel->firstNumWord;
foreach($firstNumWord as $k => $v){
if(strtolower($v) == strtolower($first_title)){
return $k;
}
$first_title = mb_substr(strtolower($title), 0, 1);
if (is_numeric($first_title)){
return 0;
}
return 27;
$string_key = array_search($first_title, $this->model->firstNumWord);
return $string_key ?: 27;
}
/**
... ... @@ -171,7 +168,6 @@ class KeywordLogic extends BaseLogic
if(empty($v)){
continue;
}
$this->model = new Keyword();
$info = $this->model->read(['title'=>$v],['id']);
if($info === false){
$param['project_id'] = $this->user['project_id'];
... ...
... ... @@ -28,6 +28,7 @@ use App\Models\RankData\Speed;
use App\Models\RankData\Speed as GoogleSpeedModel;
use App\Utils\HttpUtils;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Log;
... ... @@ -819,8 +820,19 @@ class RankDataLogic extends BaseLogic
if(!$model){
$model = new IndexedPagesModel();
}
$is_ext = 0;
$copy_domain = '';
$api = new QuanqiusouApi();
$res = $api->getSiteResPer($api_no);
//复制站 域名在这个http://api.quanqiusou.cn/google-rank/ext_sitenum_list.php里面 就用这个接口的数据
$domain = (new DomainInfo())->getDomain($domain);
$host = parse_url($domain, PHP_URL_HOST);
$host=str_replace('www.', '', $host);
$copy_site_list = $api->getSiteNumList();
if(in_array($host, $copy_site_list)){
$copy_domain = $host;
$is_ext = 1;
}
$res = $api->getSiteResPer($api_no, $is_ext, $copy_domain);
if(!$res){
Log::channel('rank_data')->error('syncIndexedPages:收录数数据为空', ['project_id' => $project_id, 'api_no' => $api_no]);
continue;
... ...
... ... @@ -77,7 +77,7 @@ class AiBlogService
'type'=>$type,
'subtype'=>$subtype,
];
$param['anchor'] = json_encode($anchor,true);
$param['anchor'] = $anchor;
$param['url'] = $this->route;
$param['mch_id'] = $this->mch_id;
$param['template_id'] = 1;
... ...