cURL not posting login data?
Hello,
I have searched much for the answer to this question; most of my Google searches bring up the same thing, the cURL manual. Done much experimentation but to no avail. I am running an automated script that compares content of a web page against the last time it was checked (using diff) to see if it was updated. Works great. Now I want to check a page (php bulletin board) which requires logging in with password. According to the cURL manual, this should be no big deal. Quote from the cURL manual: "It's easy to post data using curl." The "form" container of the page looks like this: <form action="login.php" method="post" target="_top"> <input type="text" name="username" size="25" maxlength="40" value="" /></div> <input type="password" name="password" size="25" maxlength="32" /></div> <input type="checkbox" name="autologin" /> <input type="hidden" name="redirect" value="viewforum.php?f=1&start=0" /> <input type="submit" name="login" class="mainoption" value="Log in" /><br /> </form> Following the directions from the POST (HTTP) section of the manual I enter this: (NOTE: the URL I have used in each case was entered as a full http protocol URL when running the command. I have removed the http protocol prefixes here to keep them from being parsed as a link.) curl -d "username=myusername&password=xyz123&login=Log+in&redirect=viewforum.php?f=1&start=0" bogusforums.com/login.php?redirect=viewforum.php&f=1&start=0 The URL supplied is the URL which, if I am logged out using a particular browser, this would take me to a login page, and then once the login data was entered and submitted, would normally take me right to the desired forum page. I am assuming then, that by posting the data using cURL as I have done, it should download the content of that same desired forum page. Instead, the output I get is something like this: allasso:~ allasso$curl -d "username=myusername&password=xyz123&login=Log+in&redirect=viewforum.php?f=1&start=0" bogusforums.com/login.php?redirect=viewforum.php&f=1&start=0 [1] 863 [2] 864 THEN, if I keep re-entering the same command, it looks like this (notice the numbers in brackets seem to increase sequentially): allasso:~ allasso$curl -d "username=myusername&password=xyz123&login=Log+in&redirect=viewforum.php?f=1&start=0" bogusforums.com/login.php?redirect=viewforum.php&f=1&start=0 [3] 865 [4] 866 [1] Done curl -d "username=myusername&password=xyz123&login=Log+in&redirect=viewforum.php?f=1&start=0" bogusforums.com/login.php?redirect=viewforum.php [2] Done f=1 allasso:~ allasso$curl -d "username=myusername&password=xyz123&login=Log+in&redirect=viewforum.php?f=1&start=0" bogusforums.com/login.php?redirect=viewforum.php&f=1&start=0 [5] 867 [6] 868 [3] Done curl -d "username=myusername&password=xyz123&login=Log+in&redirect=viewforum.php?f=1&start=0" bogusforums.com.com/login.php?redirect=viewforum.php [4] Done f=1 As I said, I just simply want it to download the same page that shows up when I submit data manually from a browser. I then tried entering the same information using the -F option instead of -d: curl -F "username=myusername&password=xyz123&login=Log+in&redirect=viewforum.php?f=1&start=0" bogusforums.com/login.php?redirect=viewforum.php&f=1&start=0 This gives me similar output, only this time it will download the login page (not the page I wish to be directed to), and then does not exit. If I simply press return again, I get this: [1]- Done curl -F "username=myusername&password=xyz123&login=Log+in&redirect=viewforum.php?f=1&start=0" bogusforums.com.com/login.php?redirect=viewforum.php [2]+ Done f=1 Anyone know what is going on, and what I need to do to get cURL to get past the login page and download the desired page each time? Thanks, Allasso |
my apologies for the incorrect use of "cURL".
It should be "curl" |
All times are GMT -5. The time now is 01:32 PM. |