Advertisement
Guest User

Untitled

a guest
Jan 27th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. <?PHP
  2.  
  3. $servername = "192.168.2.75";
  4. $username = "kodi";
  5. $password = "kodi";
  6. $dbname = "torrents";
  7.  
  8. // Create connection
  9. $conn = new mysqli($servername, $username, $password, $dbname);
  10.  
  11. // Check connection
  12. if ($conn->connect_error) {
  13. die("Connection failed: " . $conn->connect_error);
  14. }
  15.  
  16. # Set $count to the number of pages of torrents there currently are. The more pages, the longer it will need to execute.
  17. $count = 7;
  18.  
  19. while ($count > 0) {
  20.  
  21. #INITIAL SCRAPE OF PAGE
  22. $initial_results = array();
  23.  
  24. # Un-comment below once you've done the initial scrape
  25. #$url="https://1337x.unblocked.vc/user/QxR/";
  26.  
  27. # Comment out the below line once you've done the initial scrape
  28. $url="https://1337x.unblocked.vc/QxR-torrents/" . $count . "/";
  29.  
  30. $data=file_get_contents($url);
  31. $data = strip_tags($data,"<a>");
  32. $d = preg_split("/<\/a>/",$data);
  33. foreach ( $d as $k=>$u ){
  34. if( strpos($u, "<a href=") !== FALSE ){
  35. $u = preg_replace("/.*<a\s+href=\"/sm","",$u);
  36. $u = preg_replace("/\".*/","",$u);
  37. if( strpos($u, '/torrent/') !== FALSE) {
  38. array_push($initial_results, $u);
  39. }
  40. }
  41. }
  42.  
  43. #LOOP TO GRAB INFO FROM PAGES
  44. $reversed = array_reverse($initial_results);
  45. foreach ($reversed as $result){
  46. $title_split = explode("/", $result);
  47. $title = "'".$title_split[3]."'";
  48. $encoder=substr($title, 0, -5);
  49. $encoder="'".end(explode('-',$encoder))."'";
  50. print "TITLE: " . $title . "<br>";
  51. $url="https://1337x.unblocked.vc".$result;
  52. print "URL: <a href='" . $url . "'>" . $url . "</a><br>";
  53. $data=file_get_contents($url);
  54. $data = strip_tags($data,"<a>");
  55. $d = preg_split("/<\/a>/",$data);
  56. foreach ( $d as $k=>$u ){
  57. if( strpos($u, "href=\"magnet") !== FALSE ){
  58. $u = preg_replace("/.*href=\"/sm","",$u);
  59. $u = preg_replace("/\".*/","",$u);
  60. if( strpos($u, "magnet") !== FALSE ){
  61. print "MAGNET: <a href='" . $u . "'>MAGNET</a><br>";
  62. $start = "btih:";
  63. $end = "&dn";
  64. $hash = "'".getBetween($u,$start,$end)."'";
  65. print "HASH: " . $hash . "<br>";
  66. print "ENCODER: " . $encoder . "<br>";
  67. $check_select = mysqli_query("SELECT * FROM `old_utr` WHERE title = '$title'");
  68. $numrows=mysqli_num_rows($check_select);
  69.  
  70. if($numrows == 0){
  71.  
  72. $sql = "INSERT INTO old_utr (title,hash,encoder) VALUES ($title, $hash, $encoder)";
  73. $conn->query($sql);
  74. }
  75. else
  76. {print "Record exists";}
  77. break;
  78. }
  79. }
  80. }
  81.  
  82. }
  83.  
  84. $count = $count-1;
  85. }
  86.  
  87. function getBetween($content,$start,$end){
  88. $r = explode($start, $content);
  89. if (isset($r[1])){
  90. $r = explode($end, $r[1]);
  91. return $r[0];
  92. }
  93. return '';
  94. }
  95.  
  96. $conn->close();
  97.  
  98.  
  99.  
  100.  
  101. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement