gabarea Posted November 17, 2009 Share Posted November 17, 2009 <?php set_time_limit(0); $start = 0; $cuvant = urlencode("music"); $path = array("/images"); $url = "http://www.google.com/cse?cx=013269018370076798483%3Awdba3dlnxqm&q=$cuvant&num=100&hl=en&as_qdr=all&start=$start&sa=N "; $go = true; while( $go ) { // req google $data = get_url($url,$cuvant,$start); @preg_match_all("/<h2 class=(.*?)><a href=\"(.*?)\" class=(.*?)>/", $data, $rezultate); // verificam adca mai sunt rezultate if( count($rezultate) == 0 ) { $go = false; break; } // procesam fiecare rezultat foreach( $rezultate as $r ) { echo $r['url']."\n"; executa($r['url']); } } function get_url($url,$h=false) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); if( $h ) { curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_NOBODY, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_MAXREDIRS, 10); } curl_setopt($ch, CURLOPT_TIMEOUT, 15); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $data = curl_exec($ch); curl_close($ch); return $data; } function status($url) { $data = get_url($url,true); preg_match("/HTTP\/1\.[1|0]\s(\d{3})/",$data,$matches); if( count($matches) > 0 ) { if( $matches[1] == 200 ) return true; else return false; } else { return false; } } function scrie($fis,$txt) { $f = fopen($fis,'a'); fwrite($f,$txt); fclose($f); } function executa($url) { global $path; foreach( $path as $p ) { $site = parse_url($url); $done = "http://".$site['host']."/"; if( status($done.$p) ) { scrie("found.txt",$done.$p."\n"); echo $done.$p."\n\n\n" .$done.$p. " -> found!!\n\n\n"; } else { echo $done.$p." - 404!!\n"; } } } ?> I have this code but doesn't work how I want.. This code searches on google for all the websites that have directory /images open but doesn't parse the website I can't figure it out why Can someone help me ? Quote Link to comment https://forums.phpfreaks.com/topic/181857-cant-handle-with-this/ Share on other sites More sharing options...
MadTechie Posted November 17, 2009 Share Posted November 17, 2009 Whats not working exactly ? one thing i can see thing that just don't make logical sense is $data = get_url($url,$cuvant,$start); Yet function get_url($url,$h=false) { also echo $r['url']."\n"; can't be right i'm sure it should be loop thought the $rezultate[2] as $r and then use $r as the URL Quote Link to comment https://forums.phpfreaks.com/topic/181857-cant-handle-with-this/#findComment-959134 Share on other sites More sharing options...
gabarea Posted November 18, 2009 Author Share Posted November 18, 2009 is someone who have time and have pleasure to make my script work ? cauz I am playing with it for about one week I just can't :| Quote Link to comment https://forums.phpfreaks.com/topic/181857-cant-handle-with-this/#findComment-960187 Share on other sites More sharing options...
MadTechie Posted November 18, 2009 Share Posted November 18, 2009 Whats not working exactly ? Did you fix the logical errors ? Quote Link to comment https://forums.phpfreaks.com/topic/181857-cant-handle-with-this/#findComment-960229 Share on other sites More sharing options...
gabarea Posted November 18, 2009 Author Share Posted November 18, 2009 if you try the script on your localhost you will see it doesn't parse the websites from google results. he is trying directory /images on http:///images instead of http://site.com/images and I can't fix it.. so can you please run the script on your local and see whats the problem? I do not have other option. It is a nightmare for me this script Quote Link to comment https://forums.phpfreaks.com/topic/181857-cant-handle-with-this/#findComment-960284 Share on other sites More sharing options...
MadTechie Posted November 18, 2009 Share Posted November 18, 2009 I have already stated that reason for those errors! Quote Link to comment https://forums.phpfreaks.com/topic/181857-cant-handle-with-this/#findComment-960290 Share on other sites More sharing options...
gabarea Posted November 18, 2009 Author Share Posted November 18, 2009 yes but you told me what is wrong with that script you didn't told me how to correct it Quote Link to comment https://forums.phpfreaks.com/topic/181857-cant-handle-with-this/#findComment-960332 Share on other sites More sharing options...
MadTechie Posted November 18, 2009 Share Posted November 18, 2009 See my first post! I assume you wrote the code in the first place! Quote Link to comment https://forums.phpfreaks.com/topic/181857-cant-handle-with-this/#findComment-960451 Share on other sites More sharing options...
gabarea Posted November 18, 2009 Author Share Posted November 18, 2009 No I didn't wrote it. a friend of mine but now he is gone Quote Link to comment https://forums.phpfreaks.com/topic/181857-cant-handle-with-this/#findComment-960468 Share on other sites More sharing options...
MadTechie Posted November 18, 2009 Share Posted November 18, 2009 So now its down to you to write the code.. This is the "Help" section after all, if you want someone to do all the work your need to use the freelance section and pay for it. I have given you a few bug fixes for you to apply, let me what problems you get and I'll try to help. Quote Link to comment https://forums.phpfreaks.com/topic/181857-cant-handle-with-this/#findComment-960472 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.