Jump to content

trying to learn curl


dreamwest

Recommended Posts

Im trying to learn curl, but the script endlessly loads

 

set_time_limit(0);

// create a new cURL resource
$ch = curl_init();

// set default curl options
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11");

$g_url = http://site.com/page.html;

echo "Fetching...<br>";
curl_setopt($ch, CURLOPT_URL, $g_url);

echo "test<br>";

$html = curl_exec($ch);
echo"test2";

if (strlen($html)>0) {

echo "ok";

}

 

This echos :

 

Fetching...
test

 

Its sticking on this part for some reason:

 

$html = curl_exec($ch);

 

Link to comment
https://forums.phpfreaks.com/topic/165333-trying-to-learn-curl/
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.