作者 lyh

Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6 into develop

... ... @@ -7,6 +7,7 @@ use App\Helper\SemrushApi;
use App\Models\Domain\DomainInfo;
use App\Models\RankData\ExternalLinks as ExternalLinksModel;
use App\Models\Project\DeployOptimize;
use App\Utils\HttpUtils;
use App\Utils\LogUtils;
/**
... ... @@ -40,9 +41,12 @@ class ExternalLinks extends BaseCommands
$error = 0;
$semrushApi = new SemrushApi();
//有排名api编号的项目
$list = DeployOptimize::where('api_no', '>', 0)->pluck('domain', 'project_id')->toArray();
$list = DeployOptimize::where('api_no', '>', 0)->select('domain', 'api_no', 'project_id')->get()->toArray();
LogUtils::info('start rank_data_external_links:' . count($list));
foreach ($list as $project_id => $domain) {
foreach ($list as $item) {
$project_id = $item['project_id'];
$api_no = $item['api_no'];
$domain = $item['domain'];
if(!$domain){
continue;
}
... ... @@ -54,6 +58,16 @@ class ExternalLinks extends BaseCommands
$model = new ExternalLinksModel();
}
//5.0
try {
$data = HttpUtils::get("https://www.quanqiusou.cn/semrush-api/data_json/{$api_no}.json", []);
$data = Arr::s2a($data);
}catch (\Exception $e){
$data = [];
}
if(!$data){
//外链数据
$domain = (new DomainInfo())->getDomain($domain);
$res = $semrushApi->backlinks_overview($domain);
... ... @@ -63,6 +77,7 @@ class ExternalLinks extends BaseCommands
}
$data = $this->_data($project_id, $res['total']);
}
$model->project_id = $project_id;
$model->total = $data['total'];
... ...
... ... @@ -2,10 +2,12 @@
namespace App\Console\Commands\RankData;
use App\Helper\Arr;
use App\Helper\SemrushApi;
use App\Models\Domain\DomainInfo;
use App\Models\RankData\RecommDomain as RecommDomainModel;
use App\Models\Project\DeployOptimize;
use App\Utils\HttpUtils;
use App\Utils\LogUtils;
/**
... ... @@ -39,9 +41,12 @@ class RecommDomain extends BaseCommands
$error = 0;
$semrushApi = new SemrushApi();
//有排名api编号的项目
$list = DeployOptimize::where('api_no', '>', 0)->pluck('domain', 'project_id')->toArray();
$list = DeployOptimize::where('api_no', '>', 0)->select('domain', 'api_no', 'project_id')->get()->toArray();
LogUtils::info('start rank_data_recomm_domain:' . count($list));
foreach ($list as $project_id => $domain) {
foreach ($list as $item) {
$project_id = $item['project_id'];
$api_no = $item['api_no'];
$domain = $item['domain'];
if(!$domain){
continue;
}
... ... @@ -53,9 +58,20 @@ class RecommDomain extends BaseCommands
$model = new RecommDomainModel();
}
//5.0
try {
$data = HttpUtils::get("https://www.quanqiusou.cn/semrush-api/data_json/{$api_no}.json", []);
$data = Arr::s2a($data)['list'];
}catch (\Exception $e){
$data = [];
}
if(!$data){
//外链引荐域名
$domain = (new DomainInfo())->getDomain($domain);
$data = $semrushApi->backlinks_refdomains($domain);
}
if (!$data) {
$error++;
continue;
... ...
... ... @@ -31,6 +31,10 @@ class NoticeController extends BaseController
$referrer_url = $request->input('referrer_url');
$user_agent = $request->input('user_agent');
// 数据占时不入库, 些日志分析数据
file_put_contents(storage_path('logs/trafficVisit.log'), var_export($request->all(), true) . PHP_EOL, FILE_APPEND);
// return $this->success([]);
if (empty($ip))
return $this->error('IP不能为空');
if (empty($url))
... ... @@ -38,7 +42,6 @@ class NoticeController extends BaseController
if (empty($user_agent))
return $this->error('请求头信息user_agent不能为空');
//
$url_array = parse_url($url);
$array = [
'ip' => $ip,
... ...
... ... @@ -76,22 +76,23 @@ class UpdateController extends BaseController
$this->fail('非升级无法进行采集操作');
}
if ($this->param['test_domain']) {
$test_domain_arr = parse_url($this->param['test_domain']);
$this->param['test_domain'] = $test_domain_arr['host'] ?? '';
$test_domain = $this->param['test_domain'] ?? '';
if ($test_domain) {
$test_domain_arr = parse_url($test_domain);
$test_domain = $test_domain_arr['host'] ?? '';
}
//查看项目是否已上线
$domain_info = DomainInfo::where('project_id', $this->param['project_id'])->first();
if ($domain_info && !$this->param['test_domain']) {
if ($domain_info && !$test_domain) {
$this->fail('已上线项目需填写采集的测试站域名');
}
try {
DB::connection('custom_mysql')->statement("DELETE FROM `gl_collect_source` WHERE `origin` LIKE '%.css%' OR `origin` LIKE '%.js%'");
if ($domain_info) {
DB::connection('custom_mysql')->statement("UPDATE `gl_collect_task` SET `status` = 0,`domain` = '" . $this->param['test_domain'] . "' WHERE `language` = ''");
DB::connection('custom_mysql')->statement("UPDATE `gl_collect_task` SET `status` = 0,`domain` = '" . $test_domain . "' WHERE `language` = ''");
} else {
DB::connection('custom_mysql')->statement("UPDATE `gl_collect_task` SET `status` = 0 WHERE `language` = ''");
}
... ...