boneXXX Posted October 12, 2008 Share Posted October 12, 2008 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; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/128060-solved-fetching-a-list-of-url-domains-from-a-text-file-help/ Share on other sites More sharing options...
Lamez Posted October 12, 2008 Share Posted October 12, 2008 you should a database. Quote Link to comment https://forums.phpfreaks.com/topic/128060-solved-fetching-a-list-of-url-domains-from-a-text-file-help/#findComment-663113 Share on other sites More sharing options...
boneXXX Posted October 12, 2008 Author Share Posted October 12, 2008 Thanks for the reply, but I need to get the URL list directly from a text file. Quote Link to comment https://forums.phpfreaks.com/topic/128060-solved-fetching-a-list-of-url-domains-from-a-text-file-help/#findComment-663118 Share on other sites More sharing options...
DarkWater Posted October 12, 2008 Share Posted October 12, 2008 Do you actually know PHP, because your code makes no sense really. You're returning some random array value from readURLFile(), not even using it, and expecting fetch_html to magically work. Quote Link to comment https://forums.phpfreaks.com/topic/128060-solved-fetching-a-list-of-url-domains-from-a-text-file-help/#findComment-663119 Share on other sites More sharing options...
boneXXX Posted October 12, 2008 Author Share Posted October 12, 2008 Thanks for the reply darkwater. could you provide bit more help please? I am trying get the first 3 elements of the array and use it in the fetch_html(), how can I call the array element? Quote Link to comment https://forums.phpfreaks.com/topic/128060-solved-fetching-a-list-of-url-domains-from-a-text-file-help/#findComment-663124 Share on other sites More sharing options...
boneXXX Posted October 12, 2008 Author Share Posted October 12, 2008 How can I pass the array variable into the fetch_html function? Quote Link to comment https://forums.phpfreaks.com/topic/128060-solved-fetching-a-list-of-url-domains-from-a-text-file-help/#findComment-663135 Share on other sites More sharing options...
Lamez Posted October 12, 2008 Share Posted October 12, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/128060-solved-fetching-a-list-of-url-domains-from-a-text-file-help/#findComment-663141 Share on other sites More sharing options...
boneXXX Posted October 12, 2008 Author Share Posted October 12, 2008 Thanks I already figured out. Just you need to use the function name and the variable that you want to pass. I was just expecting answer like this, not the script. Thanks anyway. Quote Link to comment https://forums.phpfreaks.com/topic/128060-solved-fetching-a-list-of-url-domains-from-a-text-file-help/#findComment-663149 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.