update
This commit is contained in:
@ -44,24 +44,27 @@ class BaiduRecordCommand extends BaseSpider
|
|||||||
public function configure()
|
public function configure()
|
||||||
{
|
{
|
||||||
parent::configure();
|
parent::configure();
|
||||||
$this->setDescription('36kr.com');
|
$this->setDescription('查百度收录');
|
||||||
|
$this->addOption('id', 'i', InputOption::VALUE_OPTIONAL, '指定的新闻id.', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function execute(InputInterface $input, OutputInterface $output): int
|
public function execute(InputInterface $input, OutputInterface $output): int
|
||||||
{
|
{
|
||||||
|
$id = $input->getOption('id');
|
||||||
// 新闻:/touch/reconstruct/article/list/BBM54PGAwangning/0-10.html
|
$this->_start($id);
|
||||||
|
|
||||||
$this->_start();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 采集新闻板块
|
// 采集新闻板块
|
||||||
private function _start()
|
private function _start(int|bool $id = false)
|
||||||
{
|
{
|
||||||
$cache = [];
|
$cache = [];
|
||||||
$requestCookie = '';
|
$requestCookie = '';
|
||||||
AppNews::query()->where('is_delete', 0)->each(function($item) use (&$requestCookie, &$cache) {
|
$query = AppNews::query()->where('is_delete', 0)->where('is_record', 0);
|
||||||
|
if ($id) {
|
||||||
|
$query->where('id', $id);
|
||||||
|
}
|
||||||
|
$query->each(function($item) use (&$requestCookie, &$cache) {
|
||||||
try {
|
try {
|
||||||
if (!$item->platform) {
|
if (!$item->platform) {
|
||||||
throw new \Exception('没找到平台!!');
|
throw new \Exception('没找到平台!!');
|
||||||
@ -98,6 +101,7 @@ class BaiduRecordCommand extends BaseSpider
|
|||||||
if (stripos($res, '验证') !== false) {
|
if (stripos($res, '验证') !== false) {
|
||||||
$this->log->info('有验证码!!');
|
$this->log->info('有验证码!!');
|
||||||
}
|
}
|
||||||
|
var_dump($res)
|
||||||
(new Crawler($res))->filter('.abs')->each(function ($node) use ($domain, $item) {
|
(new Crawler($res))->filter('.abs')->each(function ($node) use ($domain, $item) {
|
||||||
if (stripos($node->html(), $domain) !== false) {
|
if (stripos($node->html(), $domain) !== false) {
|
||||||
$this->log->info('已收录');
|
$this->log->info('已收录');
|
||||||
|
Reference in New Issue
Block a user