- 论坛徽章:
- 0
|
本帖最后由 workingbeijing 于 2010-05-22 13:01 编辑
$target = "http://www.mysteel.com/user/login.ms";
# Define the login form data
$form_data="sUserName=coderjoy&sPassword=123456&url=http://www.mysteel.com/";
# Create the cURL session
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $target); // Define target site
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // Return page in stringcurl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt"); // Tell cURL where to write cookies
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt"); // Tell cURL which cookies to send
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $form_data);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); // Follow redirects
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
# Execute the PHP/CURL session and echo the downloaded page
$page = curl_exec($ch);
echo $page;
curl_close($ch);
这种方法不能返回登录完的状态,其它网站可以,是不是因为这个login.ms?还有没有其它的方法。其它的网站用这个方法可以登录,只有这个不可以 |
|