SHARE
TWEET

Untitled

a guest May 22nd, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. function find($string, $start, $end){
  4.     $string = ' ' . $string;
  5.     $ini = strpos($string, $start);
  6.     if ($ini == 0) return '';
  7.     $ini += strlen($start);
  8.     $len = strpos($string, $end, $ini) - $ini;
  9.     return substr($string, $ini, $len);
  10. }
  11.  
  12. $baseLink = "https://www.subito.it/annunci-italia/vendita/auto/?advt=p&o=";
  13.  
  14. $toExtract = 2000;
  15.  
  16.  
  17. for($i = 1000; $i<=$toExtract; $i++){
  18.  
  19.  
  20.     $currentPage = file_get_contents($baseLink. $i);
  21.  
  22.     $toParse = explode("<li>", $currentPage);
  23.  
  24.     foreach ($toParse as $part){
  25.  
  26.         if(strpos($part, "item_list_section item_image")){
  27.  
  28.             $link = find($part, 'item_image"> <a href="', '">');
  29.  
  30.  
  31.             $findPhone = file_get_contents($link);
  32.  
  33.             $phone = find($findPhone, 'data-prop-phone="', '"');
  34.  
  35.                         if(strlen($phone)==10){
  36.                                 if($phone[0] == 3){
  37.                         file_put_contents("phones.txt", "+39" . $phone . PHP_EOL, FILE_APPEND);
  38.  
  39.                                 echo "+39" .$phone . PHP_EOL;}
  40.                         }
  41.  
  42.         }
  43.  
  44.     }
  45.  
  46. }
  47.  
  48.  
  49. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top