update
This commit is contained in:
@ -22,11 +22,10 @@ class AutoPush extends BaseSpider
|
||||
*/
|
||||
protected string $baseUrl = 'http://data.zz.baidu.com/urls?site=https://hegsfc.com&token=5CtAd8vD3QQazJjh';
|
||||
|
||||
protected const PLATFORM = 'elle-street';
|
||||
|
||||
public function __construct(protected ContainerInterface $container, LoggerFactory $loggerFactory)
|
||||
{
|
||||
parent::__construct('baidu:auto-push');
|
||||
$this->commandLogger = $loggerFactory->get('log', 'command-baidu-auto-push');
|
||||
}
|
||||
|
||||
public function configure()
|
||||
@ -46,7 +45,6 @@ class AutoPush extends BaseSpider
|
||||
$query = AppWebsiteConfig::query()
|
||||
->select(['app_domain', 'id'])
|
||||
->where('is_delete', 0)
|
||||
->where('is_record', 0)
|
||||
->orderBy('id', 'DESC')
|
||||
->limit(10);
|
||||
if ($id = $input->getOption('platform')) {
|
||||
@ -66,7 +64,7 @@ class AutoPush extends BaseSpider
|
||||
curl_setopt_array($ch, $options);
|
||||
$result = curl_exec($ch);
|
||||
$pushArray = [];
|
||||
var_dump($result);
|
||||
$this->commandLogger->info($result);
|
||||
};
|
||||
foreach ($query as $item) {
|
||||
$article = AppNews::query()->where('platform', $item['id'])->select(['id'])->get()->toArray();
|
||||
@ -78,12 +76,6 @@ class AutoPush extends BaseSpider
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// echo $result;
|
||||
// var_dump($result);
|
||||
|
||||
var_dump($pushArray);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ class BaiduRecordCommand extends BaseSpider
|
||||
public function __construct(protected ContainerInterface $container, LoggerFactory $loggerFactory)
|
||||
{
|
||||
parent::__construct('spider:baidu-record');
|
||||
$this->log = $loggerFactory->get('log', 'command-baidu-record');
|
||||
$this->log = $loggerFactory->get('log', 'command-spider-baidu-record');
|
||||
}
|
||||
|
||||
public function configure()
|
||||
|
@ -8,7 +8,9 @@ use Hyperf\Command\Command;
|
||||
use Hyperf\Contract\StdoutLoggerInterface;
|
||||
use Hyperf\Coroutine\Coroutine;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Hyperf\Logger\LoggerFactory;
|
||||
use Laminas\Stdlib\ArrayUtils;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Swoole\Coroutine\Channel;
|
||||
use Swoole\Timer;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
@ -44,6 +46,8 @@ class BaseSpider extends Command
|
||||
|
||||
protected array $commandConfigure = [];
|
||||
|
||||
protected ?LoggerInterface $commandLogger = null;
|
||||
|
||||
private function init()
|
||||
{
|
||||
// 因为最外层还有个父协程, 所以加一
|
||||
@ -79,7 +83,7 @@ class BaseSpider extends Command
|
||||
return AppSpiderArticle::query()->where($condition)->first() ?: new AppSpiderArticle();
|
||||
}
|
||||
|
||||
protected function request(string $url): array
|
||||
protected function request(string $url, array $headers = []): array
|
||||
{
|
||||
$ch = curl_init();
|
||||
curl_setopt_array($ch, array(
|
||||
@ -88,10 +92,13 @@ class BaseSpider extends Command
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 15,
|
||||
CURLOPT_SSL_VERIFYPEER => false,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'GET',
|
||||
CURLOPT_HTTPHEADER => $headers,
|
||||
));
|
||||
|
||||
// curl_setopt($ch, CURLOPT_URL, $url);
|
||||
// curl_setopt($ch, CURLOPT_HEADER, false);
|
||||
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
@ -130,7 +137,7 @@ class BaseSpider extends Command
|
||||
$this->coroutineList[$cid] = 1;
|
||||
}
|
||||
|
||||
protected function debugPrint(array|string $message = '', $level = 0)
|
||||
protected function debugPrint(array|string $message = '', $level = 0):void
|
||||
{
|
||||
if ($this->getCommandConfigure('prod') === false) {
|
||||
$printTime = date('H:i:s');
|
||||
|
Reference in New Issue
Block a user