NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

<?php
include_once("E:/xampp/htdocs/autotruyentranh/simple_html_dom.php");

$con = mysqli_connect("localhost", "root", "");
mysqli_select_db($con, "manga");
mysqli_query($con, "set names 'utf8'");
$site = "https://truyentranhlh.net/manga-list.html?listType=allABC";
$main = "https://truyentranhlh.net/";

$html = file_get_html($site);
foreach ($html->find("#Character .char") as $col) {
foreach ($col->find("span.manga-2") as $book) {
$slug = safe($book->find("a",0)->href);
if(KiemTraSlugTonTai($slug) == true){
echo "$slug existed!"."<br />";
}else{
$linkBook = $main.$slug;
$bookData = file_get_html($linkBook);

$bTitleAlt = "";
$bAuthor = "";
$bStatus = "";
$catArr = array();
$bView = 0;
$bFollow = 0;
$bCover="";
$bExcerpt = "";
$bShow = 1;
$bNumChap = 0;


$bCover = $bookData->find(".info-cover img.thumbnail",0)->src;
$bTitle = $bookData->find(".manga-info h1",0)->innertext;
foreach ($bookData->find(".manga-info li") as $li) {
$label = $li->find("i",0)->class;
if(strpos($label, "fa-clone") !== false){
$arr = explode(":", $li->plaintext);
$bTitleAlt = safe($arr[1]);
echo $bTitleAlt; exit();
}
}
}


}
exit();
}


//for
for($i=1; $i<=143; $i++){
$page = "P".$i;
$url = "";
$url = sprintf($site, $page);
$bUrl = "";
$bTitle = "";

$rawHtml = @file_get_contents($url);
if($rawHtml !== false){
echo "##### Page $i #####n";
$html = file_get_html($url);
$k = 1;
$bookData = false;
foreach($html->find("ul.listtruyen li") as $book){
$data1 = $book->find("div.item_truyennendoc a",0);
if($data1 != null){
$bUrl = safe($main.$data1->href);
$bTitle = safe($book->find("div.item_truyennendoc a h5.tentruyen_slide", 0)->plaintext);
}else{
$bUrl = "";
}

echo "Getting Data from $bUrl...";

if(KiemTraSlugTonTai($bUrl) == false){
$bookData = @file_get_contents($bUrl);
}else{
echo "Existed! n";
continue;
}

// $indexView = 3;
$bTitleAlt = "";
$bAuthor = "";
$bStatus = "";
$catArr = array();
$bView = 0;
$bFollow = 0;
$bCover="";
$bExcerpt = "";
$bShow = 1;
$bNumChap = 0;
if($bookData !== false){
$bookAllContent = file_get_html($bUrl);
$bookInfo = $bookAllContent->find("div#content_truyen", 0);
$thumb = $bookInfo->find(".wrapper_image img", 0);
if($thumb != null){
$bCover = $thumb->src;
}

$label = "";
foreach ($bookInfo->find(".wrapper_info p") as $li) {
$labelCheck = $li->find("i",0);
if($labelCheck != null){
$label = safe($labelCheck->class);

if($label == "bg icon_tacgia"){
$bAuthorHtml = $li->find("a",0);
if($bAuthorHtml != null){
$bAuthor = $bAuthorHtml->plaintext;
}else{
$bAuthorArr = explode(":", $li->plaintext);
$bAuthor = safe($bAuthorArr[1]);
}
}else if($label == "bg icon_trangthai"){
$bStatusArr = explode(":", $li->plaintext);
$bStatus = safe($bStatusArr[1]);
}else if($label == "bg icon_theloai"){
foreach ($li->find("a") as $a ) {
$catTitle = safe($a->plaintext);
if($catTitle != "Hamtruyen"){
$catArr[] = $catTitle;
}
}
}else if($label == "bg icon_add"){
$iTotalFollow = explode(" ", $li->find("#numbertheodoi", 0)->plaintext);
$bFollow = safe($iTotalFollow[0]);
$bFollow = str_replace(",", "", $bFollow);
$iTotalView = explode("Lượt view : ", $li->plaintext);
$bView = $iTotalView[1];
$bView = str_replace(",", "", $bView);
}
}
}


$bExcerpt = safe($bookInfo->find("#tomtattruyen",0)->plaintext);

// echo $bTitle." - Title<br>";
// echo $bTitleAlt."- Title Alt<br>";
// echo $bAuthor."- Author<br>";
// echo $bStatus."- Status<br>";
// print_r($catArr)." - Cat Arr <br>";
// echo $bView." - View<br>";
// echo $bFollow." - Follow<br>";
// echo $bCover." - Cover<br>";
// echo $bExcerpt." - Excerpt<br>";
// exit();
echo "n";

$formatSQL = "INSERT INTO ht_book (bID, bTitle, bTitleAlt, bExcerpt, bCover, bAuthor, bNumChap, bView, bFollow, bSlug, bStatus, bShow) VALUES (NULL, '%s', '%s', '%s', '%s', '%s', '%d', '%d', '%d', '%s', '%d', '%d')";
$sql = sprintf($formatSQL, $bTitle, $bTitleAlt, $bExcerpt, $bCover, $bAuthor, $bNumChap, $bView, $bFollow, $bUrl, $bStatus, $bShow);

$res = mysqli_query($con, $sql);
$checkThemBook = mysqli_affected_rows($con);
if($checkThemBook > 0){
echo $k. ". Added Book Success n";

$bID = mysqli_insert_id($con);

$sql2 = "INSERT INTO ht_manga_cat(mcID, bID, catID) VALUES";
$catIndex = 0;
foreach ($catArr as $catTitle) {
$catID = getCatID($catTitle);

$formatSQL2 = ", (NULL, %d, %d)";
if($catIndex == 0){
$formatSQL2 = "(NULL, %d, %d)";
}
$f = sprintf($formatSQL2, $bID, $catID);
$sql2 .= $f;
$catIndex++;
}

// echo $sql2; exit();

$resCat = mysqli_query($con, $sql2);
$checkThemMangaCat = mysqli_affected_rows($con);
if($checkThemMangaCat > 0){
echo $k. ". Added Category for $bID Successn";
}else{
echo $k. ". Added Category for $bID Failedn";
}
}else{
echo $k. ". Added Book Failed n";
}

}//end bookData
else{
echo "Error! Can not get the siten";
}

$k++;
}//end foreach

}else{
echo "Error! Can not get the site!n";
}
echo "n===== End Page =====nn";
}//end for

function getCatID($catItem)
{
$con = mysqli_connect("localhost", "root", "");
mysqli_select_db($con, "hamtruyen");
mysqli_query($con, "set names 'utf8'");

$catID = 0;
$sql = "SELECT catID FROM category WHERE catTitle LIKE '".$catItem."'";
$result = mysqli_query($con, $sql);
if($result){
while($row = mysqli_fetch_assoc($result)){
$catID = $row["catID"];
}
}

return $catID;
}

function KiemTraSlugTonTai($slug)
{
$con = mysqli_connect("localhost", "root", "");
mysqli_select_db($con, "manga");
mysqli_query($con, "set names 'utf8'");

$check = true;
$sql = "SELECT bID FROM book WHERE bSlug LIKE '".$slug."'";
$result = mysqli_query($con, $sql);
if($result->num_rows == 0){
$check = false;
}

return $check;
}

function safe($str){
$str = str_replace("\", "", $str);
$str = str_replace("'", "''", $str);
$str = trim($str);
return $str;
}
?>
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.