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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.