Spider Source

roskata

Registered
Кажете някоя търсачка,която се индексира с spider_source и как се работи с него.Благодаря предварително. :)
 
Поне ми кажете може ли да се напише,някой скрипт който да му зададеш дадена директория(на друг сайт) и той да искарва линковете от нея. :)Това също ще ми свърши добра работа. :)
 
Ето ти едно роботче дето бях писал по-рано:

Код:
<?php
// Konfiguraciq
$link = "http://store1.data.bg/mopers/";

// Da nqma maksimalno vreme za izpalnenie
set_time_limit(0);
// Predstavqme se za Download Master, tai kato toi ima vazmojnost za barzo otvarqne na mnogo papki. Mojete da si go smenite na vseki edin ili da si napi6ete va6
ini_set('user_agent', 'Download Master');

	$ind['d'] = 0;
	$ind['f'] = 0;
	$ind['e'] = 0;
			
	$ind = get_links($link);
			
	echo "<br><br>Directories indexed: ".$ind['d'];
	echo "<br>Files indexed: ".$ind['f'];
	echo "<br>Errors: ".$ind['e'];

////////////////////////////////////////////////
function get_links($url) 
{
global $list, $ind;

// Proverqva dali e uspqlo da iztegli source koda
if ( !($source = @file_get_contents($url)) )
{
	$ind['e'] = $ind['e'] + 1;
}

// Vzima vsi4ki linkove
$preg = "/a[\s]+[^>]*?href[\s]?=[\s\"\']+(.*?)[\"\']+.*?>"."([^<]+|.*?)?<\/a>/";
preg_match_all(trim($preg), $source, $out, PREG_PATTERN_ORDER);
    
$links = $out[1];

// Za vseki link
foreach ($links as $href)
{	
	// ako e kam direktoriq
	if ( eregi("/$", $href) )
	{
		$ind['d'] = $ind['d'] + 1;
		
		echo $href."<br>";
		
		get_links($url.$href);
	}
	// ako e kam fail
	else
	{
		$ind['f'] = $ind['f'] + 1;

		echo $href."<br>";
	}
	
}

// Vra6ta informaciqta
return $ind;
}

?>
 
Точно такова роботче ми трябва,но защо като примерно индексирам "http://store1.data.bg/mopers/" ми изкарва всичко точно с "http://" (целия линк).А като индексирам,някой локален сървар ми излиза така "/CLIPS/Nsync/Justin%20Timberlake%20-%20Im%20lovin%20it.mpeg" (без http:// - то и самото IP).Някакви идеи. :)
 
fetch.class.php

Код:
<?php
//***********************************************************************
//Author  : Rahman Haqparast
//Contact : rahmanofsky@yahoo.co.uk
//License : Free for Non-commercial use
//Date    : April 2003
//Edited  : April 2005
//***********************************************************************
class fetchlinks
{
// Class Properties
// Private Varibales
	var $_isolated_links;
	var $_txt;
// Public Varibales
	var $href;
	var $caption;
	var $url;
// Constructor
// The constructor gets the url you want to retrieve its links
	function fetchlinks($_url)
	{
		$this->_txt=file_get_contents($_url);
		$this->_txt=str_replace("<A",'<a',$this->_txt);
		$this->_txt=str_replace("</A>",'</a>',$this->_txt);
		$this->url=$_url;
	}
// isolating <a>...</a>
// The _isolate() function isolates every <a>....</a> from the main text
// scope : Local 
	function _isolate()
		{
			$j = 0;
			for ($i=0;$i<=strlen($this->_txt);$i++)
			{
	
				if (substr($this->_txt,$i,1+1)=="<a") 
				{
					$j++;
					$st=$i;
					$k=$i;
					while (substr($this->_txt,$k,3)!="/a>")
					{
						$k++;
					}
					$en=$k+2+1;
					$this->_isolated_links[$j]=substr($this->_txt,$st,$en-$st);
				}
				
			}
		}		
// get_links() function extracts link data from the isolated links
// It first calls the _isolate() function and works on the isolated data
// scope : Global
	function get_links()
		{
		$this->_isolate();
			$k=0;
			$n=0;
			for ($i=1;$i<=count($this->_isolated_links);$i++)
			{
			
				for ($j=1;$j<=strlen($this->_isolated_links[$i]);$j++)
				{
// in this part we'll find what is written in href part of <a> link
					if (substr($this->_isolated_links[$i],$j,5)=='href=') 
					{
						$n++;
						$st=$j+5;
						$m=$j+5;
							while (substr($this->_isolated_links[$i],$m,1)!='>')
							{
								$m++;
							}
							$en=$m;
							$temp=substr($this->_isolated_links[$i],$st,$en-$st);
							if (strpos($temp,' ')>0) $temp=substr($temp,0,strpos($temp,' '));			
							$temp=str_replace('"','',$temp);
							$temp=str_replace("'","",$temp);
							if (substr($temp,0,1)=="/") $temp="$this->url".$temp;
							if (substr($temp,0,7)!="http://") $temp="$this->url/".$temp;
							if (!isset($p)) $p=0;
							$this->href[0]="";
							if (substr($temp,0,7)=="http://" && $temp!=$this->href[$p]) 
							{
								$p++;
								$this->href[$p]=$temp;
							}
//********************************************************************************					
// in this part we'll find link captions or in other words anything between link tag <a ....>---</a>
							while (substr($this->_isolated_links[$i],$m,1)!='>')
							{
								$m++;
							}
							$st=$m+1;
							while (substr($this->_isolated_links[$i],$m,4)!='</a>')
							{
								$m++;
							}
							$en=$m;
							if (substr($temp,0,7)=="http://") 
							{
								$this->caption[$p]=substr($this->_isolated_links[$i],$st,$en-$st);
							}
					}
				}
			}
		}
// This function will show the target of the links or in other words the href part of the <a> tag	
// if $mode is set to "0" the links will be shown without indicating numbers
// if $mode is set to anything else the links  will be shown with indicating numbers and "-->" sign
	function show_href($mode)
		{
		$this->get_links();
			for ($i=1;$i<count($this->href);$i++)
			{
					if ($mode==0) echo $this->href[$i]."\n<br>\n"; else echo $this->href[$i]."\n<br>\n";
			}
		}	
// This function will show the caption of the links.
// if $mode is set to "0" the links will be shown without indicating numbers
// if $mode is set to anything else the links  will be shown with indicating numbers and "-->" sign
	function show_caption($mode)
		{
		$this->get_links();
			for ($i=1;$i<=count($this->caption);$i++)
			{
				if ($mode==0) echo $this->caption[$i]."\n<br>\n"; else echo $i."-->".$this->caption[$i]."\n<br>\n";
			}
		}	
}
?>


fetch_sample.php
Код:
<?php
set_time_limit(300);
include "fetch.class.php";
$spider=new fetchlinks("http://dir.bg");
echo "Link Targets:<br>";
$spider->show_href(1);
?>

http://webjo-bg.info/0710/new/fetch_sample.php
 
Мерси жорка скриптчето е много-добро,но имам едно проблемче:) Всичко си е на 6 много бързо изкарва линковете,но виж как ги искарва като задам да индексира: http://10.10.10.10/Music/b/ ми искарва линковете така:
http://10.10.10.10/Music/b/Music/b/Balthazar%2C%20Jackrock%20And%20Pfs303%20-%20Pusheeet.mp3
 
намери

Код:
  if ($mode==0) echo $this->href[$i]."\n<br>\n"; else echo $this->href[$i]."\n<br>\n";


замести го с

Код:
if ($mode==0) echo $this->urldecode(href[$i])."\n<br>\n"; else echo $this->urldecode(href[$i])."\n<br>\n";
 
jooorooo каза:
намери

Код:
  if ($mode==0) echo $this->href[$i]."\n<br>\n"; else echo $this->href[$i]."\n<br>\n";


замести го с

Код:
if ($mode==0) echo $this->urldecode(href[$i])."\n<br>\n"; else echo $this->urldecode(href[$i])."\n<br>\n";
Дава ми грешка: Parse error: syntax error, unexpected '[' in C:\Program Files\xampp\htdocs\bot4e\fetch.class.php on line 117,демек на този код който заместих. :cry:
 
моя грешка

Код:
<?php 
//*********************************************************************** 
//Author  : Rahman Haqparast 
//Contact : rahmanofsky@yahoo.co.uk 
//License : Free for Non-commercial use 
//Date    : April 2003 
//Edited  : April 2005 
//*********************************************************************** 
class fetchlinks 
{ 
// Class Properties 
// Private Varibales 
   var $_isolated_links; 
   var $_txt; 
// Public Varibales 
   var $href; 
   var $caption; 
   var $url; 
// Constructor 
// The constructor gets the url you want to retrieve its links 
   function fetchlinks($_url) 
   { 
      $this->_txt=file_get_contents($_url); 
      $this->_txt=str_replace("<A",'<a',$this->_txt); 
      $this->_txt=str_replace("</A>",'</a>',$this->_txt); 
      $this->url=$_url; 
   } 
// isolating <a>...</a> 
// The _isolate() function isolates every <a>....</a> from the main text 
// scope : Local 
   function _isolate() 
      { 
         $j = 0; 
         for ($i=0;$i<=strlen($this->_txt);$i++) 
         { 
    
            if (substr($this->_txt,$i,1+1)=="<a") 
            { 
               $j++; 
               $st=$i; 
               $k=$i; 
               while (substr($this->_txt,$k,3)!="/a>") 
               { 
                  $k++; 
               } 
               $en=$k+2+1; 
               $this->_isolated_links[$j]=substr($this->_txt,$st,$en-$st); 
            } 
             
         } 
      }       
// get_links() function extracts link data from the isolated links 
// It first calls the _isolate() function and works on the isolated data 
// scope : Global 
   function get_links() 
      { 
      $this->_isolate(); 
         $k=0; 
         $n=0; 
         for ($i=1;$i<=count($this->_isolated_links);$i++) 
         { 
          
            for ($j=1;$j<=strlen($this->_isolated_links[$i]);$j++) 
            { 
// in this part we'll find what is written in href part of <a> link 
               if (substr($this->_isolated_links[$i],$j,5)=='href=') 
               { 
                  $n++; 
                  $st=$j+5; 
                  $m=$j+5; 
                     while (substr($this->_isolated_links[$i],$m,1)!='>') 
                     { 
                        $m++; 
                     } 
                     $en=$m; 
                     $temp=substr($this->_isolated_links[$i],$st,$en-$st); 
                     if (strpos($temp,' ')>0) $temp=substr($temp,0,strpos($temp,' '));          
                     $temp=str_replace('"','',$temp); 
                     $temp=str_replace("'","",$temp); 
                     if (substr($temp,0,1)=="/") $temp="$this->url".$temp; 
                     if (substr($temp,0,7)!="http://") $temp="$this->url/".$temp; 
                     if (!isset($p)) $p=0; 
                     $this->href[0]=""; 
                     if (substr($temp,0,7)=="http://" && $temp!=$this->href[$p]) 
                     { 
                        $p++; 
                        $this->href[$p]=$temp; 
                     } 
//********************************************************************************                
// in this part we'll find link captions or in other words anything between link tag <a ....>---</a> 
                     while (substr($this->_isolated_links[$i],$m,1)!='>') 
                     { 
                        $m++; 
                     } 
                     $st=$m+1; 
                     while (substr($this->_isolated_links[$i],$m,4)!='</a>') 
                     { 
                        $m++; 
                     } 
                     $en=$m; 
                     if (substr($temp,0,7)=="http://") 
                     { 
                        $this->caption[$p]=substr($this->_isolated_links[$i],$st,$en-$st); 
                     } 
               } 
            } 
         } 
      } 
// This function will show the target of the links or in other words the href part of the <a> tag    
// if $mode is set to "0" the links will be shown without indicating numbers 
// if $mode is set to anything else the links  will be shown with indicating numbers and "-->" sign 
   function show_href($mode) 
      { 
      $this->get_links(); 
         for ($i=1;$i<count($this->href);$i++) 
         { 
               if ($mode==0) echo urldecode($this->href[$i])."\n<br>\n"; else echo urldecode($this->href[$i])."\n<br>\n"; 
         } 
      }    
// This function will show the caption of the links. 
// if $mode is set to "0" the links will be shown without indicating numbers 
// if $mode is set to anything else the links  will be shown with indicating numbers and "-->" sign 
   function show_caption($mode) 
      { 
      $this->get_links(); 
         for ($i=1;$i<=count($this->caption);$i++) 
         { 
            if ($mode==0) echo $this->caption[$i]."\n<br>\n"; else echo $i."-->".$this->caption[$i]."\n<br>\n"; 
         } 
      }    
} 
?>
 
Ето:

Код:
<?php
// Konfiguraciq
$link = "http://store1.data.bg/mopers/";

// Da nqma maksimalno vreme za izpalnenie
set_time_limit(0);
// Predstavqme se za Download Master, tai kato toi ima vazmojnost za barzo otvarqne na mnogo papki. Mojete da si go smenite na vseki edin browser ili da si napi6ete va6
ini_set('user_agent', 'Download Master');

	$ind['d'] = 0;
	$ind['f'] = 0;
	$ind['e'] = 0;
			
	$ind = get_links($link);
			
	echo "<br><br>Directories indexed: ".$ind['d'];
	echo "<br>Files indexed: ".$ind['f'];
	echo "<br>Errors: ".$ind['e'];

////////////////////////////////////////////////
function get_links($url) 
{
global $list, $ind;

if ( !($source = @file_get_contents($url)) )
	return false;
	
// Vzima vsi4ki linkove
$preg = "/a[\s]+[^>]*?href[\s]?=[\s\"\']+(.*?)[\"\']+.*?>"."([^<]+|.*?)?<\/a>/";
preg_match_all(trim($preg), $source, $out, PREG_PATTERN_ORDER);

$links = $out[2];

// Za vseki link
foreach ($links as $href)
{	
	// Ako vodi kam gorna direktoriq da ne go otvarq ili ako e prazen
	if (( eregi("\<img", $href) ) or ( eregi("Име", $href) ) or ( eregi("Модифициран", $href) ) or ( eregi("Големина", $href) ) or (empty($href)) or ( eregi("Предна директория", $href) ) or ( eregi("FREE.Data.BG", $href) ) or ( eregi("webmaster@data.bg", $href) )) 
		continue;

		$href = str_replace(' ', "%20", $href);
		
	// ako e kam direktoriq
	if ( (eregi("/$", $href)) )
	{		
		if (get_links($url.$href))
		{
			echo $url.$href."<br>";
			$ind['d'] = $ind['d'] + 1;
			@ob_flush();
			flush();
		}
	}
	// ako e kam fail
	else
	{
		$ind['f'] = $ind['f'] + 1;

                        echo $url.$href."<br>";

			@ob_flush();
			flush();
	}
	
}

// Vra6ta informaciqta
return $ind;
}

?>
 
StormBreaker, скрипта много ми хареса обаче имам малък проблем. Понеже съм новичка искам да питам може ли да се преправи малко. В такъв си вид индексира файловете прекрасно, но не ги вади като линкове,a само като списък и не са декодирани. Можете ли да съдействате, моля ви?



Искам да ми ги вади като линкове и като кликна на тях да зазпочва да ги тегли. А може ли да се направи по модела на jooorooo? В смисъл да има лента горе, така:



А линковете да изглеждат така:



от скриптчето на jooorooo - без да го обиждам просто на StormBreaker по ми харесва и държа да е то, но за жалост не съм добра колкото вас :cry:
 
виж и това скриптче само че директорията се задаваше по друг начин някой може ли да го направи примерно изкара резултатите и да ги записва в база данни която напиша и таблица линкс

или със скрипта който даде StormBreaker

Код:
<?php 
$url = "http://store1.data.bg/mopers/"; 


$redove = file($url); 
$count = count($redove); 
echo "URL: ".$url."<br /><br />"; 
for($i=1; $i<=$count ;$i++){ 

if(ereg("onClick=location.href=\"".$url."(.*).mp3\" style='cursor:hand'", $redove[$i], $mp3)){ 
      if($mp3[1] != "../"){ 
      echo str_replace("%20", " ", $mp3[1])." - ".$url.$mp3[1].".mp3<br />\n"; 
      } 
} elseif(ereg("onClick=location.href=\"".$url."(.*).Mp3\" style='cursor:hand'", $redove[$i], $mp3)){ 
      if($mp3[1] != "../"){ 
      $mp3[1] = str_replace("%20", " ", $mp3[1]); 
      echo $mp3[1]."<br />\n"; 
      } 
} elseif(ereg("onClick=location.href=\"".$url."(.*).MP3\" style='cursor:hand'", $redove[$i], $mp3)){ 
      if($mp3[1] != "../"){ 
      $mp3[1] = str_replace("%20", " ", $mp3[1]); 
      echo $mp3[1]."<br />\n"; 
      } 
} 

} 
?>
 

Back
Горе