I'm a bit of a PHP newbie, so please forgive me if this question is stupid
=). Anyways, I am writing a script using curl to check a list of proxies to
make sure that they can connect to google. Unfortunately, when I run the
script I always end up getting a segmentation fault around iteration 250+.
Here is the loop from the script:

        for($i = 0; $i < $numProxies; $i++)
                //set the proxy to test
                $proxyToTest = $resultArray[1][$i];

                //try to open the google page
                $ch = curl_init();
                $googleURL = "http://www.google.com";;
                curl_setopt($ch, CURLOPT_URL, $googleURL);
                curl_setopt($ch, CURLOPT_VERBOSE, 0);
                curl_setopt($ch, CURLOPT_HEADER, 0);
                curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0
(compatible; MSIE 6.0; Windows 98)");
                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($ch, CURLOPT_PROXY, $proxyToTest);
                curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
                $googlePage = curl_exec($ch);

                //if we get a line about searching, we know everything's
dandy ;-)
                if(preg_match("/search/i", $googlePage))
                        //debug print statement
                        print "found viable proxy: $proxyToTest\n";

                        //write the proxy to file if we know it works
                        fwrite($proxyListHandle, $resultArray[1][$i] . ", "
. $resultArray[3][i] .
                                ", " . $resultArray[5][i] . "\n");

                        //increment viableProxies

                //otherwise, we can surmise there is a problem, so loop
again and make sure the same proxy
                //isn't picked
                        //debug print line
                        //print "found failed proxy: $proxyToTest\n";

                        //increment failedProxies

                if($i % 50 == 0)
                        print "checked $i proxies\n";

Thanks in advance!

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to