update
This commit is contained in:
@ -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