update
This commit is contained in:
@ -64,7 +64,7 @@ class BaiduRecordCommand extends BaseSpider
|
||||
if ($id) {
|
||||
$query = $query->where('id', $id);
|
||||
}
|
||||
$query->each(function($item) use (&$requestCookie, &$cache) {
|
||||
$query?->each(function($item) use (&$requestCookie, &$cache) {
|
||||
try {
|
||||
if (!$item->platform) {
|
||||
throw new \Exception('没找到平台!!');
|
||||
@ -77,18 +77,7 @@ class BaiduRecordCommand extends BaseSpider
|
||||
// 主域名
|
||||
$domain = trim($cache['website'][$item->platform]['app_domain'], '/');
|
||||
|
||||
if (!isset($cache['column'][$item->column_tag])) {
|
||||
$cache['column'][$item->column_tag] = AppNewsColumn::find($item->column_tag)?->toArray() ?: '';
|
||||
}
|
||||
|
||||
$column = $cache['column'][$item->column_tag]['url'] ?? '';
|
||||
|
||||
if (!isset($cache['column_2'][$item->second_column])) {
|
||||
$cache['column_2'][$item->second_column] = AppNewsSecondColumn::find($item->second_column)?->toArray() ?: '';
|
||||
}
|
||||
|
||||
$secondColumn = $cache['column_2'][$item->second_column]['url'] ?? '';
|
||||
$url = 'https://m.baidu.com/pu=sz%401321_480/from=0/ssid=0/s?word=' . urlencode("https://{$domain}{$column}{$secondColumn}/{$item->id}");
|
||||
$url = 'https://m.baidu.com/pu=sz%401321_480/from=0/ssid=0/s?word=' . urlencode("https://{$domain}/news/{$item->id}");
|
||||
|
||||
$this->log->info('正在处理' . $url);
|
||||
list($res, $code, $cookie) = $this->request($url, headers: [
|
||||
@ -101,8 +90,8 @@ class BaiduRecordCommand extends BaseSpider
|
||||
if (stripos($res, '验证') !== false) {
|
||||
$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) {
|
||||
$this->log->info('已收录');
|
||||
AppNews::find($item->id)->update(['is_record' => 1]);
|
||||
|
Reference in New Issue
Block a user