Jump to content

curl request page just loads


The Little Guy

Recommended Posts

I am using curl, it is getting urls from a page.

 

I am having a problem when it comes to pages that don't send a response back. How can I check to see if a page responds back or not?

 

$url = 'http://somesite.com/somepage.php';
mysql_free_result($sql);
$base = parse_url($url);
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, TRUE);
curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);

// grab URL and pass it to the browser
$opt = curl_exec($ch);
// close cURL resource, and free up system resources
curl_close($ch);

Link to comment
https://forums.phpfreaks.com/topic/175414-curl-request-page-just-loads/
Share on other sites

I added both of these:

curl_setopt($ch, CURLOPT_LOW_SPEED_TIME, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);

 

It seemed to fix the problem.

 

but you know whey you go to a page via web browser, and the page just sits there and loads forever... basically that is what was happening.

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.