Click to See Complete Forum and Search --> : using curl to login and change information
RepeatLoop
05-10-2004, 01:06 PM
I'm tryin to do a script that logs into a website, and submits information...
Not sure how to go about this...
If u try to login thru curl
curl "?username=name&password=blah&press=login" www.site.com
(not sure if that would work really)
it only generates an output of the page then exits....
I'm lookin for a program (or a way to implement curl) into doing something like this...login > do something in the next (reffering) page and submit > exit
any ideas?
thanks
blobaugh
05-10-2004, 01:46 PM
curl is a program to download files and the like. I don't think it submits stuff. You can always try 'man curl'
RepeatLoop
05-10-2004, 01:49 PM
yeah I think so too...
It can submit stuff I do know that...you just implement it into the url address
does anyone know a program that can do what I'm thinking about though?
bwkaz
05-10-2004, 06:39 PM
You can't do it with curl, because HTTP is completely stateless. The way logins work is, the server sets a cookie on the client machine (the cookie's value is a token, basically), and the browser sends that cookie back on subsequent requests. If the cookie's value corresponds to a user that's logged on, then the server does whatever it's supposed to based on the user.
You can't do it with any program that doesn't give you access to low-level HTTP stuff like cookies. You could use links or lynx, if you wanted to do it manually (but I'm guessing you don't). I think there might be a Perl module to allow you to control that kind of thing; try looking around at www.cpan.org -- possibly the URI module?
je_fro
05-10-2004, 06:54 PM
Perhaps you could write a script to do it easily from telnet?
GET /blah HTTP1/1
HOST blah
You know what I mean?
Or use Sockets in Java...
Exactly what bwkaz said. If you really want to do it the curl way, you need to find out the name and the value of the cookie after you log in with your browser. An easy way to do it in firefox is goto Tools-->Options-->Privacy and click the Cookies + sign. Then just select the radio box Enable Cookies-->but ask before accepting. Then you log in the normal way with your browser and it asks you would you like to receive the cookie. Then just type in:
$curl -b "name=Daniel" www.sillypage.com
Here are some more examples, scroll to the Cookies header (http://curl.haxx.se/docs/manual.html)
Hope that helps.
RepeatLoop
05-11-2004, 06:14 AM
thanks alot ppl ^^...much appreciated...
I guess I can't do what I'm after with base stuff :) I'm gonna look further into other stuff mentioned :)