Hi all, I need to create a curl loop that increments and uses the increment to access pages. URL of www.blah.com/index.asp?p=1 Code (markup): The number changes for each post on the site and some posts dont exist, ie p=4 doesnt exist it just brings a message up saying Post you are looking for doesnt exist. So what I need to do is have a script that takes the base URL upto = and then increment the counter each time but also if the page comes back post doesnt exist then skip this... Can anyone help pls? thanks
$i=1; $exit=0; while($exit<1) { curl_init("http://www.blah.com/index.asp?p=".$i); //other curl stuff //get html from curl in $data variable $data=curl_execute(); //work data variable and extract useful information // if condition - if in $data variable you find a text that indicates // no more useful data can be found -> you reached the end of your // increments than you do $exit =1; -> it will end the loop sleep(5); //you don't want to make hundreds and thousands of requests // without letting your target take its breath. You'll get noticed and banned fast. $i++; }