Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to download data from my server using wget.

I send the login details and store the cookie. I then rotate through 50 numbers to copy the data into new files. The saved files are always blank i.e 0kb file size.

My website stores data on individual pages e.g.: (i have changed my actual site name to "mywebsite")


I am trying to rotate through the numbers 50 to 1 and extract the data from each page.

The code I am using is below:


system ("wget --post-data 'username=ghssld&password=ewui394&autologin=1' --cookies=on --keep-session-cookies --save-cookies=cookie.txt '");

$x = 50;
while ($x <= 1) {
system ("wget --wait=400 --post-data 'html=true&order_id=50' --referer= --cookies=on --load-cookies=cookie.txt --keep-session-cookies --save-cookies=cookie.txt '");

system ("wget --post-data 'html=true&order_id=50' --referer= --cookies=on --load-cookies=cookie.txt --keep-session-cookies --save-cookies=cookie.txt '");

Can anyone help me modify my code so data is pulled correctly and the saved files are not blank? (I have commented the hyperlink addresses because I'm a new user and I can only post one hyperlink!) Thank you

share|improve this question
I just realized this should probably on SO not SF. – Nathan Adams Dec 15 '10 at 2:48

First off, the code you posted is using a Perl interpreter which makes 0 sense. The code does look like PHP so the tags are correct.

Second, is there a reason why you need to use wget? I would recommend curl:

If you really need to use wget, this seems like a better job for a simple BASH script.

Otherwise, you need to post more information. I'm not 100% sure, but a tool like wget should spit out error messages if something didn't work correctly.

share|improve this answer
Hi Nathan,Thanks for – James Locke Dec 22 '10 at 16:27
Thanks for your advice. I successfully used curl to extract the data i needed. I now need to extract relevant words from a series of the html files by the user. e.g. Name, Address, Mobile and DOB. I would be grateful if you could point me in the right direction so i can write a script that will extract the name, address out of each html file and put the data into a csv/text file for uploading into a spreadsheet. – James Locke Dec 22 '10 at 16:29
That is rather easy with regular expressions, but not a question for serverfault. Post your new code and question on – Nathan Adams Dec 23 '10 at 13:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.