CODE (htmlphp):
скопировать код в буфер обмена
скопировать код в буфер обмена
- <?php
- $URL= "http://www.tophotels.ru/" ;
- $content=file_get_contents($URL);
- $TAG_IN = "<h3>ОТЕЛИ ПО СТРАНАМ:</h3>";
- $TAG_OUT = '<div class="pr_th_block">';
- $position =strpos("$content",$TAG_IN);
- $content = substr($content,$position);
- $position =strpos("$content",$TAG_OUT);
- $content = substr($content,0,$position);
- $content = str_replace('<a href="/main/hotels/','<a href="http://www.tophotels.ru/main/hotels/', $content);
- preg_match_all("/http\:\/\/([^\/\s]+[a-zа-я]+)\/?(\S+[\wа-яёЁ\/\-])?/i",$content,$ssilki);
- $structur = 'Z:\home\vor\www\page';
- mkdir($structur,0700);
- $count= count($ssilki[0])-1;
- for($i=0;$i<=1;$i++){
- $structure = 'Z:\home\vor\www\page\page_';
- mkdir($structure.$i,0700);
- $fp=fopen("page/page_".$i.".html",'w');
- $Zabrat_content = file_get_contents($ssilki[0][$i]);
- $TAG_vvod = "Сравнить";
- $TAG_vivod = '<a href="/main/about2/">О проекте</a>';
- $position =strpos("$Zabrat_content",$TAG_vvod);
- $Zabrat_content = substr($Zabrat_content,$position);
- $position =strpos("$Zabrat_content",$TAG_vivod);
- $Zabrat_content = substr($Zabrat_content,0,$position);
- $Zabrat_content= str_replace('<a href="/main/hotel/','<a href="http://www.tophotels.ru/main/hotel/', $Zabrat_content);
- fwrite($fp,$Zabrat_content);
- preg_match_all("/http\:\/\/([^\/\s]+[a-zа-я]+)\/?(\S+[\wа-яёЁ])/i",$Zabrat_content,$podssilki);
- $count1= count($podssilki[0])-1;
- print_r($podssilki[0]);
- $Vetka = "page/page_$i/page_";
- for($r=0;$r<=$count1;$r++){
- $fd=fopen($Vetka.$r.".html",'w');
- // ВОТ ТУТ ОН ДОЛЖЕН ПЕРЕХВАТЫВАТЬ ССЫЛКИ ПОЛУЧЕННЫЕ ПО СТРАНАМ
- $Zabrat_content2 = file_get_contents($podssilki[0][$r]);
- $TAG_vvod1 = "Описание отеля";
- $TAG_vivod1 = "<span>Я еду в этот отель!</span>";
- $position1 =strpos("$Zabrat_content2",$TAG_vvod1);
- $Zabrat_content2 = substr($Zabrat_content2,$position1);
- $position1 =strpos("$Zabrat_content2",$TAG_vivod1);
- $Zabrat_content2 = substr($Zabrat_content2,0,$position1);
- fwrite($fd,$Zabrat_content2);
- fclose($fd);
- }
- fclose($fp);