Untitled
unknown
plain_text
3 years ago
4.6 kB
9
Indexable
<?php /** @noinspection ALL */
use Symfony\Component\DomCrawler\Crawler;
class mangaraw
{
public $app;
public $options;
function __construct()
{
$this->app = new setup();
$this->options = ['http' => ['method' => "GET", 'header' => "Accept-language: en\r\n" . "Cookie: foo=bar\r\n" . // check function.stream-context-create on php.net
"User-Agent: Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.102011-10-16 20:23:10\r\n" . "Referer: https://www.mcreader.net/jumbo/manga/\r\n"]];
}
function DSTruyen($page)
{
$html = getContent("https://www.mcreader.net/jumbo/manga/?results=" . $page, $this->options);
$crawler = new Crawler($html);
$data = $crawler->filter('.novel-list.grid.col.col2.chapters li a')->each(function (Crawler $node) {
$data['name'] = trim($node->attr('title'));
$data['url'] = "https://www.mcreader.net" . trim($node->attr('href'));
return $data;
});
return $data;
}
function ThongTinTruyen($url)
{
if(strpos($url, 'https://www.mcreader.net') !== false) {
$url = str_replace('https://www.mcreader.net', 'https://www.mcreader.net', $url);
}
$html = getContent($url, $this->options);
$crawler = new Crawler($html);
if ($manga = $crawler->filter("#novel .novel-info")) {
$outerHtml = $manga->outerHtml();
} else {
die('Có lỗi khi lấy dữ liệu!');
}
$data['name'] = trim($manga->filter('.novel-title')->text());
//$data['name'] = str_replace(' [All Chapters]','',$data[name]);
$data['views'] = 0;
$data['other_name'] = trim($manga->filter('.alternative-title')->text());
$data['other_name'] = $data['other_name'] !== "Updating" ? $data['other_name'] : "";
$data['cover'] = $crawler->filter('.fixed-img .cover img')->attr('data-src');
$data['description'] = $crawler->filter('.summary .content');
$data['description'] = $data['description']->count() > 0 ? $data['description']->text() : "";
$data['authors'] = $manga->filter('.author span[itemprop="author"]')->text();
$data['authors'] = $data['authors'] !== "Updating" ? $data['authors'] : "";
$data['status'] = $manga->filter('.header-stats .ongoing')->count();
$data['status'] = $data['status'] > 0 ? 0 : 2;
$data['list_categories'] = $manga->filter('.categories li a')->each(function ($node) {
return $node->text();
});
$chapter_list = $crawler->filter('.chapter-list');
if ($chapter_list->count() > 0) {
$data['list_chapter'] = $chapter_list->filter('li')->each(function (Crawler $node, $i) {
$node = $node->filter('a')->eq(0);
$data['name'] = trim($node->filter(".chapter-title")->text());
$data['name'] = "Chapter " . str_replace("-eng-li", "", $data['name']);
$data['url'] = "https://www.mcreader.net" . trim($node->attr('href'));
return $data;
});
$data['list_chapter'] = array_reverse($data['list_chapter']);
}
return $data;
}
function ThongTinChuong($url, $proxy = true)
{
$html = getContent($url, $this->options);
$crawler = new Crawler($html);
$response['server1'] = $crawler->filter(".content-wrap img")->each(function ($node) {
$url = $this->AddProxy($node->attr('src'));
if ($url !== "/static/img/logo.png") {
return trim($node->attr('src'));
}
});
$response['server1'] = array_filter(array_unique($response['server1']));
if ($proxy) {
foreach ($response['server1'] as $key => $img) {
$response['server1'][$key] = $this->AddProxy($img);
}
}
$response['info'] = $crawler->filter('title')->text();
return $response;
}
function AddProxy($url)
{
$url = trim($url);
$domain = parse_url($url, PHP_URL_HOST);
$url = str_replace($domain, $domain, $url);
$url = "https://manhuafast.com/proxy/index.php?url=" . base64_encode($url) . "&proxysite=mcreader&type=image.jpg";
return $url;
}
}Editor is loading...