Jump to content

URL reading..


slpctrl

Recommended Posts

Okay, here's what I'm trying to do: there's a site I know, and there are contents on each numerical page like so:

 

 

www.site.com/1.htm

www.site.com/2.htm

 

etc etc. Now, I'm trying to brute force to find a certain page. Here is my code I've got thus far:

 

<?php
$i = 1;
if($i < 135)
{
$newfile = file_get_contents("http://site.com/$i.htm");
echo $newfile;
sleep(3);
$i++;
}
?>

 

But it doesn't work. I can't really understand why. Any help??  ???

Link to comment
Share on other sites

Well if you want it to keep looping you can't just use if. Maybe try using this? D:

 

<?php
$i = 1;
do {
  $newfile = file_get_contents("http://site.com/$i.htm");
  echo $newfile;
  sleep(3);
  $i++;
}
while ($i<135);
?>

 

Otherwise I think it should work? D: Unless your site doesn't allow file_get_contents.

Link to comment
Share on other sites

minor bitch, but do..while loops are meant for conditions that don't have a set amount of iterations to them, or for when you don't know how many iterations there will be.  If you know how many iterations there will be, use a for loop instead.  It's a minor detail and having an outside $i var increment like that works too, but I mean, that's the point of a for loop

 

for ($i = 1; $i < 135; $i++) {
   // code here
}

 

Just FYI, regardless of how you loop it, understand that php is a server side language. It will completely run its course before spitting things out to your browser.  Depending on how much content is on those target pages, it may take a while to see some results, and your script may even time out.  In a case like this, I would probably suggest using javascript to make a loop and send requests individually, instead. 

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.