À. Mới viết xong upload luôn cho nóng =))
data thì tự trích xuất. ok! (chỉ có vài dòng ).
Khuyết điểm:
+ Leech thủ công.
+ Hơi tốn Bandwidth dữ liệu (leech truyện dài).
Khả năng chỉ có bấy nhiêu thôi =))
Code:
<?php /* Code by Jichan - Lier */ require('files/dom/dom.php'); define('_MRKEN_CMS',1); $headmod = 'leech'; require('incfiles/core.php'); require('incfiles/head.php'); function leech($link,$pf){ $fp = fopen ($pf, 'w+'); // Bắt đầu CURl $ch = curl_init($link); // Thiết lập giả lập trình duyệt // nghĩa là giả mạo đang gửi từ trình duyệt nào đó, ở đây tôi dùng Firefox curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0"); // Thiết lập trả kết quả về chứ không print ra curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Thời gian timeout curl_setopt($ch, CURLOPT_TIMEOUT, 1000); // Lưu kết quả vào file vừa mở curl_setopt($ch, CURLOPT_FILE, $fp); // Thực hiện download file $result = curl_exec($ch); // Đóng CURL curl_close($ch); return $result; } //curl_download('http://truyenfull.vn/mat-the-trong-sinh-chi-thieu-chu-hoanh-hanh/','files/ssss.txt',4); if(isset($_POST['link']) AND isset($_POST['num'])){ $f = ''; $link = array(); $data = array(); $story = array(); for($i=1;$i<=$_POST['num'];$i++){ $nurl = $_POST['link'].'/trang-'.$i.'/'; // Tmp_Name $f_name = md5(time()).'.'.$i.'_st'; // Path file $pf = 'files/storys/'.$f_name; // Leech leech($nurl,$pf); $data[] = array('pf' => $pf); } $i = 0; while($i<=count($data)-1){ // Get <a> $html = file_get_html($data[$i]['pf']); $count = count($html->find('.list-chapter'))-1; for($j = 0; $j<=$count;$j++){ $t = $html->find('.list-chapter',$j)->find('a'); foreach ($t as $e) { $f .= $e->outertext; } } // Write $fpc=$data[$i]['pf'].'_t'; $fp = @fopen($fpc,'w+'); fwrite($fp,$f); fclose($fp); // del cache $html->__destruct(); unset($html); $html = null; // Get link $html = file_get_html($fpc); $count = count($html->find('a')) -1; foreach($html->find('a') as $c){ $link[] = array('link' => $c->href, 'text' => $c->plaintext); } $html->__destruct(); unset($html); $html = null; unlink($fpc); unlink($data[$i]['pf']); $i++; } $count = count($link)-1; $c = array(); @mysql_query("INSERT INTO `storys` SET `id` = '{$_POST['name']}', `info` = '{$_POST['info']}'"); for($i=0;$i<=$count;$i++){ $pg = time().'.'.$i.'_st'; $pf2 = 'files/storys/'.$pg; leech($link[$i]['link'],$pf2); $html = file_get_html($pf2); $c[$i] = array('content' => $html->find('.chapter-c',0),'c-name' => $link[$i]['text']); @mysql_query("INSERT INTO `chapters` SET `sid` = '{$_POST['name']}', `cname` = '{$c[$i]['c-name']}', `content` = '{$c[$i]['content']}'"); unlink($pf2); } echo'<div class="gmenu">Hoàn thành</div>'; } else { ?> <form action="" method="post"> <input type="text" name="link" placeholder="Link"><br/> <input type="text" name="name" placeholder="Tên truyện"><br/> <textarea name="info" placeholder="Thông tin (Tác giả, tình trang...)"></textarea><br/> <input type="number" name="num" placeholder="Số trang chứa chapter"><br/> <input type="submit" value="leech"> </form> <?php } require('incfiles/end.php');