Jump to content

php script that visits a range of dynamic urls


myscripting

Recommended Posts

Can you create a php script that executes or visits a set of dynamic urls such as

 

http://www.mysite.com/blah&u=y

http://www.mysite.com/blah&u=y+1

http://www.mysite.com/blah&u=y+2

http://www.mysite.com/blah&u=y+3

.

.

.

http://www.mysite.com/blah&u=x

 

 

 

a range y though x? and with a delay of n seconds between urls?

 

thanks

 

PS i know it's something link this:

http://www.askapache.com/php/curl-multi-downloads.html

 

but how do you do it for an arbitrary range array?

Depends if you want to show the results in the browser, or just run the script without output. If the former, you could use javascript and an iframe. If the latter then something like this:

 

<?php
$time=1; $y=0; $x=10;

for ($i=$y;$i<=$x;$i++)
{
    $ch = curl_init();
    $url = "http://www.mysite.com/blah?u=".$i;
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_exec($ch);
    curl_close($ch);
    sleep($time);
}

?>

 

But beware, while this is running, the browser will appear to be loading nothing, and may timeout.

can you access the urls okay by typing them in?, i.e. http://www.mysite.com/blah?u=0, http://www.mysite.com/blah?u=1, etc.

 

could it be timing out? try a low value of $x

 

do curl functions in php work at all on your server - try a simple script to test them

 

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.google.com");
curl_exec($ch);
curl_close($ch);

 

 

don't see how cookies are relevant

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.