The Little Guy Posted September 24, 2009 Share Posted September 24, 2009 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 More sharing options...
Handy PHP Posted September 24, 2009 Share Posted September 24, 2009 Well, the most basic method would be to check if $opt has a value... If there isn't a response then no value would be set for $opt. Or am I missing something? Handy PHP Link to comment https://forums.phpfreaks.com/topic/175414-curl-request-page-just-loads/#findComment-924410 Share on other sites More sharing options...
The Little Guy Posted September 24, 2009 Author Share Posted September 24, 2009 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. Link to comment https://forums.phpfreaks.com/topic/175414-curl-request-page-just-loads/#findComment-924434 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.