Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function find($string, $start, $end){
- $string = ' ' . $string;
- $ini = strpos($string, $start);
- if ($ini == 0) return '';
- $ini += strlen($start);
- $len = strpos($string, $end, $ini) - $ini;
- return substr($string, $ini, $len);
- }
- $baseLink = "https://www.subito.it/annunci-italia/vendita/auto/?advt=p&o=";
- $toExtract = 2000;
- for($i = 1000; $i<=$toExtract; $i++){
- $currentPage = file_get_contents($baseLink. $i);
- $toParse = explode("<li>", $currentPage);
- foreach ($toParse as $part){
- if(strpos($part, "item_list_section item_image")){
- $link = find($part, 'item_image"> <a href="', '">');
- $findPhone = file_get_contents($link);
- $phone = find($findPhone, 'data-prop-phone="', '"');
- if(strlen($phone)==10){
- if($phone[0] == 3){
- file_put_contents("phones.txt", "+39" . $phone . PHP_EOL, FILE_APPEND);
- echo "+39" .$phone . PHP_EOL;}
- }
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement