WhiteHatLinkData.php
2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
/**
* @remark :
* @name :AuthorityScore.php
* @author :lyh
* @method :post
* @time :2025/7/1 16:43
*/
namespace App\Console\Commands\WhiteHatProject;
use App\Models\AuthorityScore\AuthorityScore;
use App\Models\Domain\DomainInfo;
use App\Models\Project\Project;
use Illuminate\Console\Command;
class WhiteHatLinkData extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'white_hat_link_data';
/**
* The console command description.
*
* @var string
*/
protected $description = '白帽外链数据详情,每月统计一次';
/**
* @remark :执行方法
* @name :handle
* @author :lyh
* @method :post
* @time :2025/7/1 16:46
*/
public function handle(){
$projectModel = new Project();
$projectIdArr = $projectModel->selectField(['project_type'=>1,'delete_status' => 0,'extend_type'=>0,'type'=>2],'id');
$domainModel = new DomainInfo();
$url = 'https://www.cmer.site/api/domain/organic?domain=';
foreach ($projectIdArr as $item){
$domainInfo = $domainModel->read(['project_id'=>$item],['domain']);
if($domainInfo === false){
continue;
}
$url = $url.$domainInfo['domain'];
$data = http_get($url);
if(!empty($data) && !empty($data['data'])){
$data = $data['data'];
$this->saveHandleData($data,$item);
}
}
return true;
}
/**
* @remark :保存数据
* @name :handleData
* @author :lyh
* @method :post
* @time :2025/7/1 17:23
*/
public function saveHandleData($data,$project_id){
$authorityScoreModel = new AuthorityScore();
return $authorityScoreModel->addReturnId([
'project_id'=>$project_id,
'ascore'=>(int)$data['ascore'],
'total'=>(int)$data['total'],
'domains_num'=>(int)$data['domains_num'],
'rank'=>(int)$data['rank'],
'organic_keywords'=>(int)$data['organic_keywords'],
'organic_traffic'=>(int)$data['organic_traffic'],
]);
}
}