Jump to content

launching several cURL posts without waiting to download pages..


tiganulmeu

Recommended Posts

Hy there, ok, i`ll get to the problem:

My php script has a function named curl(some curl options and instructions), it doesn`t matter that, what it matters:

$var1 = curl("http://www.somedomain.com/somepage1.php");

$var2 = curl("http://www.somedomain.com/somepage2.php");

$var3 = curl("http://www.somedomain.com/somepage3.php");

$var4 = curl("http://www.somedomain.com/somepage4.php");

 

Ok, so it downloades the content of somepage_.php to the $vars, however somepage_s_.php contains several scripts which takes a verry long time for the page to download, so my script waits for each page to download, one by one, as line by line, what i would like do rezolve is to start the curl without waiting to download the first page, then the second and so on, it should start the download of all the pages at almoust the same time. That would be all, please help, i`ve lost 4 nights trying to get this fixed but no luck  :(

OK, was a good ideea but running a background process won`t be posible as i don`t have command line access, is there anything else i can do ? like a function or class.  Or maybe if i can discconect the download right after i start the curl to somepage.php as i used ignore_user_abort on the somepage1.php and i don`t need really need the download to complete ...... New ideeas ? :)

I`m already using the explorer version, to launch them in separate windows but it`s more complicated .. and i need to "upgrade" ...  maybe we can fix this with some curl option or timer, this is the function i`m using:

 

 

function curl($url, $cookie='', $post='') {

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt ($ch, CURLOPT_REFERER, $url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

if($post !== '') {

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_POSTFIELDS, $post);

}

if($cookie !== '') {

curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);

curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);

}

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

$result = curl_exec ($ch);

curl_close ($ch);

if($result == "") { curl($url, $cookie, $post); } else { return $result; }

}

 

EOF

 

 

What do you think, can i somehow disconnect after a period of time ?...

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.