Untitled
unknown
php
4 years ago
5.9 kB
6
Indexable
<?php
namespace Crawler;
use Symfony\Component\DomCrawler\Crawler;
use Curl\Curl;
class Tumanhwas
{
public $referer = 'https://tumanhwas.club';
public $proxy = false;
public $curl;
function __construct()
{
$this->curl = new Curl();
$this->curl->setReferrer($this->referer);
}
function list($page)
{
$url = "https://tumanhwas.club/list-manga";
$curl_respone = $this->curl($url);
if ($curl_respone) {
$crawler = new Crawler($curl_respone);
$data = $crawler->filter('.recoment_box .story_item .story_images a')->each(function (Crawler $node) {
return trim($node->attr('href'));
});
}
//print_r($data);
return $data;
}
function info($url)
{
$total_curl = 0;
$curl_respone = $this->curl($url);
$is_curl = true;
if ($curl_respone) {
$crawler = new Crawler($curl_respone);
$manga = $crawler->filter('.iedu_header');
if ($manga->count() <= 0) {
return die('Có lỗi khi lấy dữ liệu!');
}
$outerHtml = $manga->eq(0)->outerHtml();
$data['name'] = $manga->filter('.detail_name h1')->text();
$data['other_name'] = remove_html(explode_by('Títulos alternativos</div>', '</span>', $outerHtml));
$data['other_name'] = $data['other_name'] === 'Updating' ? NULL : $data['other_name'];
if($crawler->filter('meta[property="og:image"]')->count() > 0){
$data['cover'] = $crawler->filter('meta[property="og:image"]')->eq(0)->attr('content');
} else {
$data['cover'] = $crawler->filter('.detail_avatar img')->attr('src');
}
$data['description'] = $crawler->filter('.detail_reviewContent')->text();
$data['status'] = remove_html(explode_by('Status</div>', '</span>', $outerHtml));
$data['status'] = slugGenerator($data['status']) == 'On Going' ? 'completed' : 'on-going';
// $data['type'] = remove_html(explode_by("Type\n</h5>\n</div>", '</div>', $outerHtml));
// $data['type'] = slugGenerator($data['type']) == 'Manhwa' ? 'manga' : 'manhwa';
$data['taxonomy']['source'][] = $url;
$data['taxonomy']['authors'] = remove_html(explode_by('Autor</div>', '</a></div>', $outerHtml));
$data['taxonomy']['authors'] = $data['taxonomy']['authors'] !== "Updating" ? $data['taxonomy']['authors'] : NULL;
$data['taxonomy']['genres'] = explode_by('Géneros</div>', '</div>', $outerHtml);
$data['taxonomy']['genres'] = remove_html($data['taxonomy']['genres']);
$data['taxonomy']['genres'] = explode('-', $data['taxonomy']['genres']);
$data['taxonomy']['genres'] = array_filter(array_map('trim', $data['taxonomy']['genres']), 'strlen');
// $data['taxonomy']['translation'] = $manga->filter('.artist-content a')->each(function (Crawler $node) {
// return trim($node->text());
// });
$data['list_chapter'] = $crawler->filter('.detail_chapterContent .chapter_box ul li .chapter_num')->each(function (Crawler $node) {
// if($node->count() <= 0){
// return null;
// }
// $node = $node->filter("a")->eq(0);
$chapter['name'] = mb_convert_case(trim($node->text()), MB_CASE_TITLE, "UTF-8");
if ((preg_match('#(chapter|chương|chap|capítulos)(.[\d.]+)#is', $chapter['name'], $name) || preg_match('#([C]+)([\d.]+)#is', $chapter['name'], $name)) && !empty($name[2])) {
$chapter['name'] = 'Capítulos '. trim($name[2]);
} elseif(is_numeric($chapter['name'])){
$chapter['name'] = 'Capítulos '. trim($chapter['name']);
}
$chapter['url'] = 'https://tumanhwas.club' . trim($node->attr('href'));
return $chapter;
});
$data['list_chapter'] = array_reverse(array_filter($data['list_chapter']));
return $data;
}
}
function content($url)
{
$curl_respone = $this->curl($url);
if ($curl_respone) {
$crawler = new Crawler($curl_respone);
$chapter['type'] = 'image';
$chapter['content'] = $crawler->filter('.chapter_boxImages .image_story.imageChap img')->each(function (Crawler $node) {
//return $this->AddProxy(trim($node->attr('data-src')));
return trim($node->attr('src'));
});
return $chapter;
}
return exit("lỗi");
}
// function AddProxy($url)
// {
// $url = trim($url);
// $url = "https://thcomic.com/proxy/index.php?url=" . base64_encode($url) . "&proxysite=zinmanga";
// return $url;
// }
function change_category($key){
$key = trim($key);
return mb_convert_case(
[
]
[$key] ?? $key, MB_CASE_TITLE, "UTF-8");
}
function curl($url){
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_REFERER, $this->referer);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$resp = curl_exec($curl);
curl_close($curl);
return $resp;
}
}
Editor is loading...