|
|
Posted by NC on 01/14/06 19:25
DJ Majestik wrote:
>
> I am trying to login to a particular site, login, then do a screen
> scrape after the "session" is logged in with curl. The screen
> scrape with curl works, and the login with curl (as a post)
> works, but when I put them together using the same $ch,
> the screen scrape is of the html that is not logged in.
You are not storing cookies set by the login page. Consequently, when
you try to access Page.asp, you are doing it without authentication.
Here's a slightly reworked code snippet:
$ch = curl_init();
$email = 'email';
$pass = '*****';
$submit = "Log In";
$curlPost = 'email=' . urlencode($email) .
'&pass=' . urlencode($pass) .
'&submit=' . urlencode($submit);
$cookieFile = '/tmp/myCookieFile.txt';
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFile);
curl_setopt($ch, CURLOPT_URL, 'Login.asp');
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
$data = curl_exec($ch);
echo $data . "<BR><BR>\n\n";
curl_close ($ch);
unset($ch);
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile);
curl_setopt($ch, CURLOPT_URL, 'Page.asp');
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
echo($data);
Cheers,
NC
[Back to original message]
|