Reply to Re: curl PHP screen scrape after login question

Your name:

Reply:


Posted by DJ Majestik on 07/02/05 11:37

NC,

I have modified my file the following way, but it still seems not to be
logging me in in the second request. I knwo in Firefox the cookie.txt
file manages the cookies, so not sure what I am doing wrong? Maybe the
wrong location? How would I know whwere a particular user stores their
cookies?

// INIT CURL
$ch = curl_init();

// SET URL FOR THE POST FORM LOGIN
curl_setopt($ch, CURLOPT_URL, 'Login.asp');

// ENABLE HTTP POST
curl_setopt ($ch, CURLOPT_POST, 1);

// SET POST PARAMETERS : FORM VALUES FOR EACH FIELD
$email = 'email';
$pass = 'password';
$submit2 = "Log In";
$curlPost = 'email=' . urlencode($email) . '&pass=' . urlencode($pass)
.. '&submit2=' . urlencode($submit2);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $curPost);

// IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIES
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');

# Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL
# not to print out the results of its query.
# Instead, it will return the results as a string return value
# from curl_exec() instead of the usual true/false.
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

// EXECUTE 1st REQUEST (FORM LOGIN)
$store = curl_exec ($ch);

// SET FILE TO DOWNLOAD
curl_setopt($ch, CURLOPT_URL, 'hartist.asp');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');

// EXECUTE 2nd REQUEST (FILE DOWNLOAD)
$content = curl_exec ($ch);

// CLOSE CURL
curl_close ($ch);

echo $content;
exit;

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация