Code lấy tất cả tên truyện trong libary ego

8 bài đăng
Tags:
10.08.2015 / 23:10
thaian2009
Bài đăng: 709
Member
PHP
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5.  
  6. <title>Untitled Document</title>
  7. </head>
  8.  
  9. <body>
  10.  
  11. <?php
  12. ini_set('max_execution_time', 0);
  13. ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 6.0)');
  14. function url_get_contents($url) {
  15. $data=NULL;
  16. $data=file_get_contents($url);
  17. if($data)
  18. {
  19. preg_match("/<body(.*?)>(.+?)<\/body>/s", $data, $matches);
  20. $data=$matches[2];
  21. }
  22. return $data;
  23. }
  24. //lấy danh mục
  25. $links='http://kembong.wap.mu/library.php?';
  26. $nguon= url_get_contents($links);
  27. $html = $nguon;
  28. $inx=0;
  29. $tvuid=array();$tvname=array();
  30. preg_match_all("/<a href=\"(.*?)\">(.*?)<\/a>/", $html, $matches, PREG_SET_ORDER);
  31.  
  32. foreach ($matches as $val) {
  33. if(stristr($val[1],"cid="))
  34. {
  35. $tvuid[$inx]= "" . substr(substr($val[1],strrpos($val[1], '=', -5)),1);
  36. $tvname[$inx]="".$val[2];
  37. $inx=$inx+1;
  38. }
  39. }
  40. //echo implode(", ",$tvuid);
  41. //echo implode(", ",$tvname);
  42. //echo "<br/>";
  43. //lấy tên truyện
  44. $i=0;$tvuidx=array();$tvnamex=array();
  45. for($i;$i<count($tvuid);$i++)
  46. {
  47. $linksx='';
  48. $linksx='http://kembong.wap.mu/library.php?id=cat&cid='.$tvuid[$i].'';$nguonx='';
  49. $nguonx= url_get_contents($linksx);
  50. $htmlx = $nguonx;
  51. preg_match_all("/<a href=\"(.*?)\">(.*?)<\/a>/", $htmlx, $matchesx, PREG_SET_ORDER);
  52. foreach ($matchesx as $valx) {
  53. if(stristr($valx[1],"tid="))
  54. {
  55. $tvuidx[$i]=$tvuidx[$i]. "" . substr(substr($valx[1],strrpos($valx[1], '=', -7)),1).",";
  56. //echo substr(substr($valx[1],strrpos($valx[1], '=', -7)),1);
  57. $tvnamex[$i]=$tvnamex[$i]."".$valx[2].",";
  58. //echo $valx[2];
  59. }
  60. elseif(stristr($valx[1],"dir="))
  61. {
  62. $dirid='';$dirid=substr(substr($valx[1],strrpos($valx[1], '=', -7)),1);
  63. $linksxs='';
  64. $linksxs='http://kembong.wap.mu/library.php?id=cat&cid='.$tvuid[$i].'&dir='.$dirid.'';$nguonxs='';
  65. $nguonxs= url_get_contents($linksxs);
  66. $htmlxs = $nguonxs;
  67. preg_match_all("/<a href=\"(.*?)\">(.*?)<\/a>/", $htmlxs, $matchesxs, PREG_SET_ORDER);
  68. foreach ($matchesxs as $valxs) {
  69. if(stristr($valxs[1],"tid="))
  70. {
  71. $tvuidx[$i]=$tvuidx[$i]. "" . substr(substr($valxs[1],strrpos($valxs[1], '=', -7)),1).",";
  72. $tvnamex[$i]=$tvnamex[$i]."".$valxs[2].",";
  73. }
  74. }
  75. }
  76. }
  77. }
  78.  
  79. //echo implode(", ",$tvuidx);
  80. //echo implode(", ",$tvnamex);
  81. for($y=0;$y<count($tvuid);$y++)
  82. {
  83. $amind=split(",",$tvuidx[$y]);$aname=split(",",$tvnamex[$y]);
  84. for($u=0;$u<count($amind);$u++)
  85. {
  86. echo $aname[$u]."<br>";
  87. }
  88. }
  89. ?>
  90.  
  91. </body>
  92. </html>

Nguồn: http://cobethoitiet.wap.mu

Đã chỉnh sửa. MrKen (24.05.2017 / 18:52)
10.08.2015 / 23:15
mvideo
Bài đăng: 70
Member
Anh Hùng Bàn Phím

tác dụng của nó ?

10.08.2015 / 23:17
MrKen
Bài đăng: 2646
Trùm!
Vẫn là A N H

chưa test nhưng thanks for share :D

10.08.2015 / 23:24
thaian2009
Bài đăng: 709
Member
mvideo đã viết

tác dụng của nó ?

Tìm tất cả tên truyện trong libary của trang đó. Có thể lấy được tên truyện. tid truyện, cat id, tên thư mục..

Định làm tools back up truyện nhưng giờ để dành làm tool tìm kiếm truyện :)

Cách làm tool tìm truyện là lấy tid và tên truyện.

Dạng {%set truyen={"tid1":"tên truyện 1","tid2":"tên truyện 2"}%}

Dùng vòng for kiểm tra từ khóa trong mảng truyen

dùng in hoặc starts with để kiểm tra

11.08.2015 / 16:11
mad
Bài đăng: 2434
Member
Nhào vô cắn tao đi, tao sợ mày à cắn bừa.

Code hại não. Nhìn nhức óc quá

11.08.2015 / 16:28
thaian2009
Bài đăng: 709
Member

uk, viết để dùng dc thôi, muốn ngắn thì fix lại nhanh mà

11.08.2015 / 16:30
b0ysh0ckhn
Bài đăng: 1146
Member
Nguyễn Minh Phương
mad đã viết

Code hại não. Nhìn nhức óc quá

có gì mà hại não....cũng như mọi tool khác thôi mà ^^

11.08.2015 / 16:33
thaian2009
Bài đăng: 709
Member
b0ysh0ck_hn đã viết

có gì mà hại não....cũng như mọi tool khác thôi mà ^^

(y) like