Page 1 of 1

Can a PHP script log into a public site with username/pass?

Posted: Thu Mar 20, 2008 8:15 pm
by doncoglioni
Hi all! :)

I have a script which analyses HTML documents and summarises some information for them, related to my work. The script itself works fine, if I have access to the HTML pages concerned. However, most of the ones I need are only accessible when I log in to a (public) website with a username and password field.

So my question is this: can a PHP script automatically "enter" the username and password, and log into the website, then (remaining authenticated for that session) fetch the protected pages that I need, just as if a human was sitting doing the same thing? No captchas are involved. Obviously I would need some information regarding the target page's username/password form and method of submission... but how would I go about doing this, generally?

My sincere thanks for any help.

Re: Can a PHP script log into a public site with username/pass?

Posted: Thu Mar 20, 2008 8:33 pm
by hayson1991
doncoglioni wrote:Hi all! :)

I have a script which analyses HTML documents and summarises some information for them, related to my work. The script itself works fine, if I have access to the HTML pages concerned. However, most of the ones I need are only accessible when I log in to a (public) website with a username and password field.

So my question is this: can a PHP script automatically "enter" the username and password, and log into the website, then (remaining authenticated for that session) fetch the protected pages that I need, just as if a human was sitting doing the same thing? No captchas are involved. Obviously I would need some information regarding the target page's username/password form and method of submission... but how would I go about doing this, generally?

My sincere thanks for any help.
I've been wondering about that too.

Re: Can a PHP script log into a public site with username/pass?

Posted: Thu Mar 20, 2008 9:05 pm
by doncoglioni
hayson1991 wrote:I've been wondering about that too.
I found this, it might be what I'm looking for. But any suggestions, please let me know:
http://www.wagerank.com/2007/how-to-sub ... -with-php/

Re: Can a PHP script log into a public site with username/pass?

Posted: Sat Mar 22, 2008 10:32 am
by mVeliki
Use CURL.

Re: Can a PHP script log into a public site with username/pass?

Posted: Sat Mar 22, 2008 3:30 pm
by Oren
Of course PHP can. What's the difference between a normal user who sends POST/GET data and a PHP script which does the same?