I want to automatically login on a website (POST with cookie) then fill a couple of forms.
1/I tried to do it using curl, but I am not sure that is possible. At least I have not managed to do it using the
curl --cookie mycookie.txt --data "login=mylogin&password=mypassword&Button=Login" [the url of the website]
”Edit”
here is the result of the curl command (including the header –include):
Content-Type: text/html
Server: Microsoft-IIS/6.0
X-Powered-By: PHP/5.2.6
Set-Cookie: PHPSESSID=b865a8e357d4f945e576aebe4f288320; path=/
Set-Cookie: cookiename=deleted; expires=Wed, 14-Jul-2010 06:43:26 GMT
X-Powered-By: PleskWin
X-Powered-By: ASP.NET
Date: Thu, 14 Jul 2011 06:43:26 GMT
Connection: close
<html>
<head>
<title>:: Welcome ::</title>
<link rel="stylesheet" type="text/css" href="Styles/textset.css">
<script language="JavaScript" type="text/javascript">
//Begin CCS script
//Include Common JSFunctions @1-252A7665
</script>
<script language="JavaScript" src="ClientI18N.php?file=Functions.js&locale=en" type="text/javascript" charset="utf-8"></script>
<script language="JavaScript" src="HeaderFunctions.js" type="text/javascript"></script>
<script language="JavaScript" type="text/javascript">
//End Include Common JSFunctions
//_OnLoad @1-9C4F01C0
function _OnLoad()
{
var result = true;
//End _OnLoad
//Set Focus @23-D20FE9BF
if (document.forms["Login"] && document.forms["Login"].login) document.forms["Login"].login.focus();
//End Set Focus
//Close _OnLoad @1-BC33A33A
return result;
}
//End Close _OnLoad
//bind_events @1-C1F288D9
function bind_events() {
if (functionExists("header_bind_events")) header_bind_events();
if (functionExists("footer_bind_events")) footer_bind_events();
addEventHandler("", "load", _OnLoad);
}
//End bind_events
window.onload = bind_events; //Assign bind_events @1-19F7B649
//End CCS script
</script>
<link rel="stylesheet" type="text/css" href="Styles/sitename/Style.css">
</head>
...
Does anyone knows what is this CSS script that executes on load? Could it be the reason why I can’t login with curl?
How can I know if it is because I am doing something wrong, or because this method cannot work (as I have read on a few posts on SO.)?
2/Another idea would be to use a tool that manipulates chrome (or any browser) to make it press the different buttons. Does this kind of software exists?
Thanks
Looks like a job for PhantomJS. As PhantomJS is built on WebKit, just like Chrome, its behavior should not be that far from Chrome’s.