<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Utils\CommonUtils;
|
|
use QL\QueryList;
|
|
|
|
class ComicsService {
|
|
|
|
private $queryInstance;
|
|
public function __construct()
|
|
{
|
|
$this->queryInstance = QueryList::getInstance();
|
|
}
|
|
|
|
/**
|
|
* @return QueryList|null
|
|
*/
|
|
public function getQueryInstance(): ?QueryList
|
|
{
|
|
return $this->queryInstance;
|
|
}
|
|
|
|
public function scrapeAllAlbum($rootUrl)
|
|
{
|
|
$content = $this->getQueryInstance()->get($rootUrl);
|
|
$rules = [
|
|
// 采集文章标题
|
|
'title' => ['.thumbnail','title'],
|
|
// 采集链接
|
|
'link' => ['.thumbnail','href'],
|
|
// 采集缩略图
|
|
'totalNum' => ['body > section > div.content-wrap > div > div.pagination.pagination-multi > ul > li:nth-child(8) > span','text'],
|
|
];
|
|
// $links = $content->find("a.thumbnail")->attrs("href");
|
|
$range = ".pb article";
|
|
$list = $content->rules($rules)->range($range)->query()->getData();;
|
|
dump($list->all());
|
|
// $totalPageNum = body > section > div.content-wrap > div > div.pagination.pagination-multi > ul > li:nth-child(8) > span
|
|
// $links->dump();
|
|
}
|
|
}
|