myscripting Posted April 7, 2010 Share Posted April 7, 2010 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? Quote Link to comment Share on other sites More sharing options...
leehanken Posted April 7, 2010 Share Posted April 7, 2010 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. Quote Link to comment Share on other sites More sharing options...
myscripting Posted April 7, 2010 Author Share Posted April 7, 2010 i tried it and i wonder why i'm getting a 500 Servlet Exception error. do I need to pass cookies? Quote Link to comment Share on other sites More sharing options...
leehanken Posted April 8, 2010 Share Posted April 8, 2010 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.