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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

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.