1

I am using curl to extract some data of a website.First time it works perfectly , but now it not parse any data from the website.I think they are blocked my server ip.So I can use public proxy ip.But still it not working.My code is ,

        $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $urls);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_PROXYPORT, '3127');
    curl_setopt($ch, CURLOPT_PROXYTYPE, 'HTTP');
    curl_setopt($ch, CURLOPT_PROXY, '204.93.54.15');
    $original_file = curl_exec($ch);
curl_close($ch);

I can't get user name and password of public proxies.Is it important to set public proxy's username and password?It don't show any errors.Any one please help me.

Navaneetha Nair
  • 312
  • 2
  • 12

2 Answers2

4

Here is a good answer to use proxy in curl

How to use CURL via a proxy?

Please check this. If you have any queries feel free to ask. Thanks

Community
  • 1
  • 1
  • ,Sorry I can't extract the data.It shows an error " Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in ".I am set safe mode off in htaccess "php_flag safe_mode Off"but it still shows the error – Navaneetha Nair Nov 29 '13 at 06:41
0

Close your connection when you are done with it. That should do the trick.

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $urls);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXYPORT, '3127');
curl_setopt($ch, CURLOPT_PROXYTYPE, 'HTTP');
curl_setopt($ch, CURLOPT_PROXY, '204.93.54.15');
$original_file = curl_exec($ch);

print_r($original_file);
curl_close($ch);
Lohardt
  • 1,057
  • 1
  • 12
  • 26