feature: wen xue guan crawler
This commit is contained in:
@@ -65,7 +65,7 @@ class Scheduler
|
|||||||
switch ($CustomCrawlerModel->cc_code) {
|
switch ($CustomCrawlerModel->cc_code) {
|
||||||
case 'PULL_WEN_XUE_GUAN':
|
case 'PULL_WEN_XUE_GUAN':
|
||||||
$arrTask = [
|
$arrTask = [
|
||||||
'callback' => [WenXueWang::class, 'createCrawlWenXueGuanTask'],
|
'callback' => [WenXueGuan::class, 'createCrawlWenXueGuanTask'],
|
||||||
'data' => [
|
'data' => [
|
||||||
'cc_data' => $CustomCrawlerModel->cc_data
|
'cc_data' => $CustomCrawlerModel->cc_data
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use app\model\ChapterModel;
|
|||||||
use app\model\CustomCrawlerModel;
|
use app\model\CustomCrawlerModel;
|
||||||
use app\model\NovelModel;
|
use app\model\NovelModel;
|
||||||
use app\task\crawler\custom\page\Site;
|
use app\task\crawler\custom\page\Site;
|
||||||
use app\task\crawler\wenxuewang\Scheduler as WxwScheduler;
|
use app\task\crawler\wxg\Scheduler as WxgScheduler;
|
||||||
use app\task\crawler\zw\page\NovelPage;
|
use app\task\crawler\zw\page\NovelPage;
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
use microserver\QueueManage;
|
use microserver\QueueManage;
|
||||||
@@ -17,7 +17,7 @@ use storage\StorageCore;
|
|||||||
/**
|
/**
|
||||||
* @mixin think\Model
|
* @mixin think\Model
|
||||||
*/
|
*/
|
||||||
class WenXueWang
|
class WenXueGuan
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Undocumented variable
|
* Undocumented variable
|
||||||
@@ -48,7 +48,7 @@ class WenXueWang
|
|||||||
$arrCcData = json_decode($arrData['cc_data'], true);
|
$arrCcData = json_decode($arrData['cc_data'], true);
|
||||||
foreach ($arrCcData as $intNSourceId) {
|
foreach ($arrCcData as $intNSourceId) {
|
||||||
$arrTask = [
|
$arrTask = [
|
||||||
'callback' => [WxwScheduler::class, 'getNovelInfo'],
|
'callback' => [WxgScheduler::class, 'getNovelInfo'],
|
||||||
'data' => [
|
'data' => [
|
||||||
[
|
[
|
||||||
'n_source_id' => $intNSourceId,
|
'n_source_id' => $intNSourceId,
|
||||||
@@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace app\task\crawler\wenxuewang;
|
namespace app\task\crawler\wxg;
|
||||||
|
|
||||||
use app\model\ChapterModel;
|
use app\model\ChapterModel;
|
||||||
use app\task\crawler\wenxuewang\page\Site;
|
use app\task\crawler\wxg\page\Site;
|
||||||
use microserver\QueueManage;
|
use microserver\QueueManage;
|
||||||
use storage\StorageCore;
|
use storage\StorageCore;
|
||||||
|
|
||||||
@@ -130,6 +130,7 @@ class Scheduler
|
|||||||
}
|
}
|
||||||
|
|
||||||
$arrChapterList = $NovelPage->getChapters();
|
$arrChapterList = $NovelPage->getChapters();
|
||||||
|
|
||||||
$this->fetchChapter($NovelPage->intNId, $NovelPage->getData()['page'], $arrChapterList);
|
$this->fetchChapter($NovelPage->intNId, $NovelPage->getData()['page'], $arrChapterList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace app\task\crawler\wenxuewang\page;
|
namespace app\task\crawler\wxg\page;
|
||||||
|
|
||||||
use db\mongo\MongoBase;
|
use db\mongo\MongoBase;
|
||||||
use ddl\DDLManage;
|
use ddl\DDLManage;
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace app\task\crawler\wenxuewang\page;
|
namespace app\task\crawler\wxg\page;
|
||||||
|
|
||||||
use app\model\ChapterModel;
|
use app\model\ChapterModel;
|
||||||
use storage\StorageCore;
|
use storage\StorageCore;
|
||||||
@@ -55,15 +55,10 @@ class ChapterPage extends BasePage
|
|||||||
|
|
||||||
$this->arrChapterInfo = [];
|
$this->arrChapterInfo = [];
|
||||||
|
|
||||||
$strPattern = "/qsbs\.bb\('([^']*)'\)/";
|
|
||||||
|
|
||||||
preg_match_all($strPattern, $this->getContent(), $arrMatches);
|
$strContent = $this->getQueryList()->find('.showtxt')->eq(0)->html();
|
||||||
|
|
||||||
$strContent = '';
|
$strContent = strip_tags($strContent, ['<script>', '</script>']);
|
||||||
|
|
||||||
foreach ($arrMatches[1] as $str) {
|
|
||||||
$strContent .= base64_decode($str);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->strChapterContent = $strContent;
|
$this->strChapterContent = $strContent;
|
||||||
|
|
||||||
@@ -71,21 +66,8 @@ class ChapterPage extends BasePage
|
|||||||
$this->arrChapterInfo['c_page_keywords'] = $this->getQueryList()->find('meta[name="keywords"]')->attr('content');
|
$this->arrChapterInfo['c_page_keywords'] = $this->getQueryList()->find('meta[name="keywords"]')->attr('content');
|
||||||
$this->arrChapterInfo['c_page_description'] = $this->getQueryList()->find('meta[name="description"]')->attr('content');
|
$this->arrChapterInfo['c_page_description'] = $this->getQueryList()->find('meta[name="description"]')->attr('content');
|
||||||
|
|
||||||
$strPattern = "/lastread\.set\((.*?)\);/";
|
$this->arrChapterInfo['c_name'] = $this->getQueryList()->find('.content')->eq(0)->find('h1')->eq(0)->text();
|
||||||
|
$this->arrChapterInfo['c_name'] = trim($this->arrChapterInfo['c_name']);
|
||||||
if (preg_match($strPattern, $this->getContent(), $arrMatches)) {
|
|
||||||
$strMatch = $arrMatches[1]; // 提取括号内的内容
|
|
||||||
|
|
||||||
$arrData = array_map('trim', explode(",", $strMatch));
|
|
||||||
|
|
||||||
$arrData = array_map(function ($item) {
|
|
||||||
return trim($item, "'");
|
|
||||||
}, $arrData);
|
|
||||||
|
|
||||||
$this->arrChapterInfo['c_page_data'] = $arrData;
|
|
||||||
} else {
|
|
||||||
$this->arrChapterInfo['c_page_data'] = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->arrChapterInfo;
|
return $this->arrChapterInfo;
|
||||||
@@ -112,8 +94,7 @@ class ChapterPage extends BasePage
|
|||||||
if (
|
if (
|
||||||
empty($arrPageChapter) ||
|
empty($arrPageChapter) ||
|
||||||
empty($arrPageChapter['c_page_title']) ||
|
empty($arrPageChapter['c_page_title']) ||
|
||||||
empty($arrPageChapter['c_page_data']) ||
|
empty($arrPageChapter['c_name'])
|
||||||
count($arrPageChapter['c_page_data']) < 5
|
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -122,7 +103,7 @@ class ChapterPage extends BasePage
|
|||||||
|
|
||||||
$arrChapter = [
|
$arrChapter = [
|
||||||
'n_id' => $intNId,
|
'n_id' => $intNId,
|
||||||
'c_name' => $arrPageChapter['c_page_data'][3],
|
'c_name' => $arrPageChapter['c_name'],
|
||||||
'c_sort_num' => $this->arrData['c_sort_num'],
|
'c_sort_num' => $this->arrData['c_sort_num'],
|
||||||
'c_page' => $this->arrData['c_page'],
|
'c_page' => $this->arrData['c_page'],
|
||||||
'c_source_id' => $this->arrData['c_source_id'],
|
'c_source_id' => $this->arrData['c_source_id'],
|
||||||
@@ -130,6 +111,7 @@ class ChapterPage extends BasePage
|
|||||||
'c_source_uuid' => $strUUId,
|
'c_source_uuid' => $strUUId,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
$arrExistsChapter = $this->getChapterModel()->findOne(['c_source_uuid' => $strUUId], $this->arrOptions);
|
$arrExistsChapter = $this->getChapterModel()->findOne(['c_source_uuid' => $strUUId], $this->arrOptions);
|
||||||
|
|
||||||
if ($arrExistsChapter) {
|
if ($arrExistsChapter) {
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace app\task\crawler\wenxuewang\page;
|
namespace app\task\crawler\wxg\page;
|
||||||
|
|
||||||
use app\model\NovelModel;
|
use app\model\NovelModel;
|
||||||
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace app\task\crawler\wenxuewang\page;
|
namespace app\task\crawler\wxg\page;
|
||||||
|
|
||||||
use app\model\CategoryModel;
|
use app\model\CategoryModel;
|
||||||
use app\model\CountersModel;
|
use app\model\CountersModel;
|
||||||
@@ -360,22 +360,21 @@ class NovelPage extends BasePage
|
|||||||
{
|
{
|
||||||
if ($this->arrChapters === NULL) {
|
if ($this->arrChapters === NULL) {
|
||||||
$this->arrChapters = [];
|
$this->arrChapters = [];
|
||||||
if ($this->isMobile()) {
|
|
||||||
$strClass = '.chapter-list';
|
|
||||||
} else {
|
|
||||||
$strClass = '.section-list';
|
|
||||||
}
|
|
||||||
|
|
||||||
$intDivIndex = 0;
|
$this->getQueryList()->find('.listmain dl')->children('dt, dd')->each(function ($item) {
|
||||||
if ($this->arrData['page'] == 0) {
|
if ($item->is('dt')) {
|
||||||
$intDivIndex = 1;
|
if ($item->find('a')->count() === 0) {
|
||||||
}
|
$this->arrChapters = [];
|
||||||
|
}
|
||||||
$this->getQueryList()->find($strClass)->eq($intDivIndex)->find("a")->map(function ($A) {
|
} elseif ($item->is('dd')) {
|
||||||
$this->arrChapters[] = [
|
$a = $item->find('a');
|
||||||
'name' => $A->text(),
|
if ($a->count() > 0) {
|
||||||
'uri' => $A->attr('href'),
|
$this->arrChapters[] = [
|
||||||
];
|
'uri' => $a->attr('href'),
|
||||||
|
'name' => $a->text()
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return $this->arrChapters;
|
return $this->arrChapters;
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace app\task\crawler\wenxuewang\page;
|
namespace app\task\crawler\wxg\page;
|
||||||
|
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
use GuzzleHttp\Promise;
|
use GuzzleHttp\Promise;
|
||||||
@@ -32,7 +32,7 @@ class Site
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $strSiteCode = 'wenxuewang';
|
protected $strSiteCode = 'wxg';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undocumented function
|
* Undocumented function
|
||||||
Reference in New Issue
Block a user