AiDomainTask.php
1.5 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
<?php
/**
* @remark :
* @name :AiDomainTask.php
* @author :lyh
* @method :post
* @time :2025/6/19 10:53
*/
namespace App\Console\Commands\Ai;
use App\Models\Domain\DomainInfo;
use Illuminate\Console\Command;
/**
* @remark :拉取项目Ai域名
* @name :AiDomainTask
* @author :lyh
* @method :post
* @time :2025/6/19 10:54
*/
class AiDomainTask extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'ai_domain';
/**
* The console command description.
*
* @var string
*/
protected $description = '获取对应域名的ai复制站域名';
public $url = 'https://www.cmer.site/api/globalso_site';
public function handle(){
$data = [];
$pageSize = 100;
$page = 1;
$domainInfoModel = new DomainInfo();
$res = http_get($this->url.'?pagesize='.$pageSize.'&page='.$page);
if($res['status'] != 200){
echo date('Y-m-d H:i:s').'请求失败,未拉取到数据';
return false;
}
$data = $res['data']['data'];
while($page <= $res['data']['last_page']){
$res = http_get($this->url.'?pagesize='.$pageSize.'&page='.$page);
if($res['status'] != 200){
echo date('Y-m-d H:i:s').'第'.$page.'请求失败,未拉取到数据';
return false;
}
$data = array_values(array_merge($data,$res['data']['data']));
$page++;
}
dd($data);
}
}