hello. i am not getting the webpage loaded using proxy. can some one please find the bug in it. $proxies = array(); // Declaring an array to store the proxy list $url = "http://www.quora.com"; // Adding list of proxies to the $proxies array $proxies[] = '109.73.70.165:5005'; // Some proxies require IP and port number $proxies[] = '198.148.112.46:7808'; // Choose a random proxy if (isset($proxies)) { // If the $proxies array contains items, then $proxy = $proxies[array_rand($proxies)]; // Select a random proxy from the array and assign to $proxy variable } $ch = curl_init(); // Initialise a cURL handle // Setting proxy option for cURL if (isset($proxy)) { // If the $proxy variable is set, then curl_setopt($ch, CURLOPT_PROXY, $proxy); // Set CURLOPT_PROXY with proxy in $proxy variable } // Set any other cURL options that are required curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_URL, $url); $results = curl_exec($ch); // Execute a cURL request curl_close($ch); // Closing the cURL handle
This code works fine (with proxy 198.148.112.46:7808). Maybe you forgot line echo $results; at the end
The easiest way to search for errors is to output variables every time the code changes. Do a var_dump($variable)
Can you access SSH and try to query CURL via command line? Have you tried with curl_error()? http://us2.php.net/curl_error Have you tried with curl_setopt($ch, CURLOPT_VERBOSE, true); There are many ways to debug CURL!
The first proxy is not working, the second one yes. Transform your proxy array in a variable with just the second proxy. More details below: Proxy 109.73.70.165:5005 is not able to open a single site, I used the second one via Terminal and it worked for me. ~$ curl -x 198.148.112.46:7808 "http://www.quora.com" --verbose * Rebuilt URL to: http://www.quora.com/ * Hostname was NOT found in DNS cache * Trying 198.148.112.46... * Connected to 198.148.112.46 (198.148.112.46) port 7808 (#0) > GET http://www.quora.com/ HTTP/1.1 > User-Agent: curl/7.35.0 > Host: www.quora.com > Accept: */* > Proxy-Connection: Keep-Alive > < HTTP/1.1 200 OK < Content-Type: text/html; charset=utf-8 < Date: Mon, 09 Jun 2014 20:36:18 GMT < Set-Cookie: m-b="oB46SqyELAVqiTmefkBSag\075\075"; Domain=.quora.com; Max-Age=675919361; Path=/; expires=Fri, 09-Nov-2035 23:59:00 GMT; HttpOnly < Set-Cookie: m-s="-Jx_kYOE4koS5cl4SkVxJA\075\075"; Domain=.quora.com; Path=/; HttpOnly < Expires: Fri, 01 Jan 1990 00:00:00 GMT < X-Frame-Options: SAMEORIGIN < Cache-Control: private, no-store, max-age=0, no-cache, must-revalidate, post-check=0, pre-check=0 < X-UA-Compatible: IE=Edge, chrome=1 * Server PasteWSGIServer/0.5 Python/2.7.2 is not blacklisted < Server: PasteWSGIServer/0.5 Python/2.7.2 < Pragma: no-cache < X-Instart-Request-ID: 7666410320286160481:YNK01-NPPRY09:1402346178:34 < X-Cache: MISS from CacheServer < X-Cache-Lookup: MISS from CacheServer:3127 < Transfer-Encoding: chunked < Via: 1.1 CacheServer (squid/3.2.13) < Connection: keep-alive