|
...
|
...
|
@@ -146,64 +146,68 @@ class WebTraffic extends Command |
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
|
|
|
$type = $this->argument('type');
|
|
|
|
try {
|
|
|
|
$type = $this->argument('type');
|
|
|
|
|
|
|
|
$this->sleep($type);
|
|
|
|
$this->sleep($type);
|
|
|
|
|
|
|
|
$page = 1;
|
|
|
|
while (true){
|
|
|
|
$project_list = $this->getProjectList($type, $page);
|
|
|
|
if(!$project_list){
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
$need_project = [];
|
|
|
|
foreach ($project_list as $project) {
|
|
|
|
//随机引流间隔
|
|
|
|
$res_sjjg = $this->get_rand($this->sjjg);
|
|
|
|
if ($res_sjjg == 1) {
|
|
|
|
continue;
|
|
|
|
$page = 1;
|
|
|
|
while (true){
|
|
|
|
$project_list = $this->getProjectList($type, $page);
|
|
|
|
if(!$project_list){
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
$need_project = [];
|
|
|
|
foreach ($project_list as $project) {
|
|
|
|
//随机引流间隔
|
|
|
|
$res_sjjg = $this->get_rand($this->sjjg);
|
|
|
|
if ($res_sjjg == 1) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$project_urls = $this->getProductUrls($project['project_id']);
|
|
|
|
$project_urls['home'] = $project['domain'];
|
|
|
|
//随机访问页面
|
|
|
|
$project['visit_urls'] = $this->getVisitUrls($project_urls);
|
|
|
|
//随机客户端
|
|
|
|
$project['device_port'] = $this->get_rand($this->yddzb);
|
|
|
|
$project['user_agent'] = $project['device_port'] == 1 ? Arr::random($this->pc_ua) : Arr::random($this->mobile_ua);
|
|
|
|
$project_urls = $this->getProductUrls($project['project_id']);
|
|
|
|
$project_urls['home'] = $project['domain'];
|
|
|
|
//随机访问页面
|
|
|
|
$project['visit_urls'] = $this->getVisitUrls($project_urls);
|
|
|
|
//随机客户端
|
|
|
|
$project['device_port'] = $this->get_rand($this->yddzb);
|
|
|
|
$project['user_agent'] = $project['device_port'] == 1 ? Arr::random($this->pc_ua) : Arr::random($this->mobile_ua);
|
|
|
|
|
|
|
|
$need_project[] = $project;
|
|
|
|
}
|
|
|
|
//随机访问ip
|
|
|
|
$ips = $this->getIpAreas(count($need_project));
|
|
|
|
//最多10层深度
|
|
|
|
$client = new Client(['verify' => false]);
|
|
|
|
for ($j = 0; $j < 10; $j++) {
|
|
|
|
$need_project[] = $project;
|
|
|
|
}
|
|
|
|
//随机访问ip
|
|
|
|
$ips = $this->getIpAreas(count($need_project));
|
|
|
|
//最多10层深度
|
|
|
|
$client = new Client(['verify' => false]);
|
|
|
|
for ($j = 0; $j < 10; $j++) {
|
|
|
|
//并发请求
|
|
|
|
$promises = [];
|
|
|
|
foreach ($need_project as $project_key => $project) {
|
|
|
|
if (empty($project['visit_urls'][$j])) {
|
|
|
|
continue;
|
|
|
|
for ($j = 0; $j < 10; $j++) {
|
|
|
|
//并发请求
|
|
|
|
$promises = [];
|
|
|
|
foreach ($need_project as $project_key => $project) {
|
|
|
|
if (empty($project['visit_urls'][$j])) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$data = [
|
|
|
|
'ip' => $ips[$project_key]['ip'],
|
|
|
|
'referer' => $this->getReferer($ips[$project_key]['ip_area']),
|
|
|
|
'url' => $project['visit_urls'][$j],
|
|
|
|
'device_port' => $this->get_rand($this->yddzb)
|
|
|
|
];
|
|
|
|
Log::channel('traffic')->info('traffic project_id:' . $project['project_id'], $data);
|
|
|
|
$promises[] = $client->postAsync($project['domain'] . 'api/customerVisit', ['form_params' => $data]);
|
|
|
|
}
|
|
|
|
Utils::settle($promises)->wait();
|
|
|
|
|
|
|
|
$data = [
|
|
|
|
'ip' => $ips[$project_key]['ip'],
|
|
|
|
'referer' => $this->getReferer($ips[$project_key]['ip_area']),
|
|
|
|
'url' => $project['visit_urls'][$j],
|
|
|
|
'device_port' => $this->get_rand($this->yddzb)
|
|
|
|
];
|
|
|
|
Log::channel('traffic')->info('traffic project_id:' . $project['project_id'], $data);
|
|
|
|
$promises[] = $client->postAsync($project['domain'] . 'api/customerVisit', ['form_params' => $data]);
|
|
|
|
//每个深度随机等待
|
|
|
|
sleep(rand(2, 10));
|
|
|
|
}
|
|
|
|
Utils::settle($promises)->wait();
|
|
|
|
|
|
|
|
//每个深度随机等待
|
|
|
|
sleep(rand(2, 10));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$page++;
|
|
|
|
$page++;
|
|
|
|
}
|
|
|
|
}catch (\Exception $e){
|
|
|
|
Log::channel('traffic')->error($e->getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
...
|
...
|
|