I would like to use CURL in order to fill in the username-password form
at the top right of this page http://www.lusa.pt/lusaweb/
I found the variable names in the page's code and tried the curl approach to
no avail (see below)...
Any suggestions ????
Code:
<form action="/lusaweb/dologin" method="post" name="frmLogin">
<table height="100%" cellpadding="0" cellspacing="0" border="0">
<tr><td colspan="2" height="50%"></td></tr>
<tr>
<td align="right" class="login-text" nowrap="nowrap"> Utilizador </td>
<td><input type="text" size="9" class="login" name="username" /></td>
<td> </td>
</tr>
<tr>
<td align="right" class="login-text" nowrap="nowrap"> Senha </td>
<td><input type="password" size="9" class="login" name="password" /></td>
<td> <button type="submit" height="15" style="background-color:#C4201F;border:0"><img border=0 src="/lusaweb/images/go.gif" title="Autenticar"></button></td>
</tr>
<tr><td colspan="2" height="50%"></td></tr>
</table>
</form>
My attempt so far failing:
Code:
$url = "http://www.lusa.pt/lusaweb/"; // This page contains Login form
$postfields='username=toto&password=titi&action=/lusaweb/dologin';
$ch=curl_init($url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
$page=curl_exec($ch);
curl_close($ch);
echo $page;
Last edited by devroot; 07-10-2009 at 05:57 AM..
Reason: Removed user's pass
|