Skip to content

Instantly share code, notes, and snippets.

@nghyane
Last active October 15, 2022 12:31
Show Gist options
  • Select an option

  • Save nghyane/273289b05424df27fa7bdcfbf96e3772 to your computer and use it in GitHub Desktop.

Select an option

Save nghyane/273289b05424df27fa7bdcfbf96e3772 to your computer and use it in GitHub Desktop.
<?php
namespace App\Crawler;
use App\MadaraCore;
use Symfony\Component\DomCrawler\Crawler;
class Kissmanga extends MadaraCore
{
public $list_url = "https://1stkissmanga.io/manga/page/%s/";
public $referer = "https://1stkissmanga.io/";
public $proxy = false;
public $chapter_type = 'image';
function info($url)
{
$html = $this->minifier($this->bypass($url));
$crawler = new Crawler($html);
$data['name'] = $crawler->filter(".post-title h1")->text();
if (!$data['name']) {
return [];
}
$post_content = $crawler->filter('.post-content_item')->each(function (Crawler $node) {
return $node->outerHtml();
});
foreach ($post_content as $item) {
if (strpos($item, 'Alternative') !== false) {
$data['other_name'] = (new Crawler($item))->filter(".summary-content")->text();
if ($data['other_name'] == 'Updating') {
unset($data['other_name']);
}
}
if (strpos($item, 'Status') !== false) {
$data['status'] = (new Crawler($item))->filter(".summary-content")->text();
$data['status'] = ($data['status'] === 'OnGoing') ? 'on-going' : 'completed';
}
}
$data['cover'] = @$crawler->filter('meta[property="og:image"]')->attr('content');
$crawler->filter(".description-summary .summary__content a")->each(function (Crawler $crawler) {
foreach ($crawler as $node) {
$node->parentNode->removeChild($node);
}
});
if ($crawler->filter(".description-summary .summary__content")->count() > 0) {
$data['description'] = $this->strip_word_html($crawler->filter(".description-summary .summary__content")->outerHtml());
}
$data['taxonomy']['wp-manga-genre'] = $crawler->filter(".genres-content a")->each(function (Crawler $node) {
return trim($node->text());
});
$data['taxonomy']['wp-manga-author'] = $crawler->filter(".author-content a")->each(function (Crawler $node) {
return trim($node->text());
});
array_filter($crawler->filter(".post-content_item")->each(function (Crawler $node) use (&$data) {
$text = $node->text();
if (strpos($text, 'Type') !== false) {
$data['type'] = $node->filter(".summary-content")->text();
if ($data['type'] == 'Updating') {
unset($data['type']);
}
}
if (strpos($text, 'Tag(s)') !== false) {
$data['taxonomy']['wp-manga-tag'] = $node->filter(".summary-content a")->each(function (Crawler $node) {
return trim($node->text());
});
}
if (strpos($text, 'Release') !== false) {
$released = trim($node->filter(".summary-content a")->text());
if (is_int($released)) {
$data['released'] = $released;
}
}
}));
$data['list_chapter'] = array_reverse(array_filter($crawler->filter(".listing-chapters_wrap .wp-manga-chapter")->each(function (Crawler $node) {
$node = $node->filter('a')->eq(0);
if (!trim($node->text())) {
return null;
}
return [
'name_extend' => '',
'name' => trim($node->text()),
'url' => $node->attr('href')
];
})));
return $data;
}
function content($url)
{
$html = $this->bypass($url);
$crawler = new Crawler($html);
$chapter['type'] = 'image';
$chapter['content'] = $crawler->filter(".reading-content .page-break")->each(function (Crawler $node) {
$img = $node->filter("img")->eq(0)->attr("data-lazy-src");
$img = trim(str_replace('//home', '/home', $img));
return "https://img.wibulord.com/proxy/?referer=https://1stkissmanga.io/&url=" . urlencode($img);
});
return $chapter;
}
function bypass($url)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_REFERER, $this->referer);
curl_setopt($curl, CURLOPT_DNS_USE_GLOBAL_CACHE, 0);
curl_setopt($curl, CURLOPT_DNS_CACHE_TIMEOUT, 0);
curl_setopt($curl, CURLOPT_RESOLVE, [
'1stkissmanga.io:443:162.19.136.30',
]);
$res = (curl_exec($curl));
curl_close($curl);
return $res;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment