Jump to content

[SOLVED] fetching a list of URL domains from a text file !HELP!


boneXXX

Recommended Posts

Hey guys,

 

I am trying to fetch list of URLs by using snoopy.

 

What I am trying to do is; I've got list of URL addresses in .txt file and I want to fetch them one by one.

 

So what I did is, I wrote a function to get each line of the text file (which are URL addresses) in an array and then I tried call this array in the snoopy function. Unfortunately i couldn't succeed.

 

I need help to figure out am I on teh right track or not. or should I try something different?

 

Any help is appreciated. Cheers.

 

I did something like this:

<?php

//Function that reads the urllist text file 

fetch_html();
readURLfile();


function readURLfile()
{	
//Get the content into an array
$url_list = file("urllist.txt");
//Get the array size
$arr_size = 2;//count($url_list);

//Loop to print each array element(line)
for ( $urllist_line = 0; $urllist_line <= $arr_size ; $urllist_line = $urllist_line +1) 
{	
	echo $url_list[$urllist_line];
	echo"</br>";
}
return $url_list[$urllist_line];
}

function fetch_html()
{ 
	//Snoopy
	include "./Snoopy-1.2.3/Snoopy.class.php";
	$snoopy = new Snoopy;

	//snoopy proxy configuration
	$snoopy->proxy_host = "...";
	$snoopy->proxy_port = "...";
	$snoopy->proxy_user = "...";
	$snoopy->proxy_pass = "...";

	if($snoopy->fetch("$url_list[$urllist_line]"))
	{
	echo "response code: ".$snoopy->response_code."<br>\n";
	while(list($key,$val) = each($snoopy->headers))
	echo $key.": ".$val."<br>\n";
	echo "<p>\n";
	echo "<PRE>".htmlspecialchars($snoopy->results)."</PRE>\n";
}
else
{
	echo "error fetching document: ".$snoopy->error."\n";
}

return $snoopy;
}



?>

 

   

usually witting your own script is best, and it gives you a fully understanding how it works.

I suggest you make your own.

 

here is a good start: http://www.google.com/search?hl=en&safe=off&q=file+open+php&btnG=Search

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.