Jump to content

Getting URL content using Perl


abhishekphp6

Recommended Posts

I am using the following function to get the contents of a URL

 

function get_data($url)

{

$ch = curl_init();

$timeout = 5;

curl_setopt($ch,CURLOPT_URL,$url);

curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);

curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,1000);

$data = curl_exec($ch);

curl_close($ch);

return $data;

}

 

However the problem is that if the request times out, the function doesn't return an error.

 

If I call the same URL in browser, I can see error message ... but the function call to get_data returns nothing if the call times out.

Link to comment
https://forums.phpfreaks.com/topic/195108-getting-url-content-using-perl/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.