function get($url)
{
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT,10);
$content = curl_exec($ch);
curl_close($ch);
return $content;
}
//打开呀里妈妈登陆页面
$url="http://www.alimama.com/member/minilogin.htm";
$add = get($url);//得到页面中的一个随机值
preg_match("/<input name='_tb_token_' type='hidden' value='(.*)'>/isU",$add,$cadd);
#echo $cadd[1];
$cookie = dirname(__FILE__).'/cookie1.txt';
$surl='http://www.alimama.com/member/minilogin_act.htm';
$curlPost = "_tb_token_=".$cadd[1]." & logname=************* & logpasswd=********* & originalLogpasswd=********** & proxy=http://www.alimama.com/proxy.htm & redirect='' & style='' ";
$ch = curl_init($surl);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_exec($ch);
curl_close($ch);求助 提交的数据有问题还是? 获取不到正确的cookie.
http://www.alimama.com/member/minilogin.htmalimamacurlcookieurl
{
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT,10);
$content = curl_exec($ch);
curl_close($ch);
return $content;
}
//打开呀里妈妈登陆页面
$url="http://www.alimama.com/member/minilogin.htm";
$add = get($url);//得到页面中的一个随机值
preg_match("/<input name='_tb_token_' type='hidden' value='(.*)'>/isU",$add,$cadd);
#echo $cadd[1];
$cookie = dirname(__FILE__).'/cookie1.txt';
$surl='http://www.alimama.com/member/minilogin_act.htm';
$curlPost = "_tb_token_=".$cadd[1]." & logname=************* & logpasswd=********* & originalLogpasswd=********** & proxy=http://www.alimama.com/proxy.htm & redirect='' & style='' ";
$ch = curl_init($surl);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_exec($ch);
curl_close($ch);求助 提交的数据有问题还是? 获取不到正确的cookie.
http://www.alimama.com/member/minilogin.htmalimamacurlcookieurl
<input type="hidden" name="style" value="" />
<input type="hidden" name="redirect" value="" />
<input type="hidden" name="proxy" value="" />
后3个不提交是否可以?如果可以,他要他们做什么?print_r(get_headers('http://www.alimama.com/member/minilogin.htm'));Array
(
[0] => HTTP/1.1 200 OK
[1] => Server: Tengine
[2] => Date: Fri, 18 Oct 2013 01:24:51 GMT
[3] => Content-Type: text/html;charset=UTF-8
[4] => Connection: close
[5] => Vary: Accept-Encoding
[6] => Set-Cookie: cookie2=e06642156d5ce9afdaea41ce9294cae3;Domain=.alimama.com;Path=/;HttpOnly
[7] => Set-Cookie: _tb_token_=6OWE4tYt9fm;Domain=.alimama.com;Path=/;HttpOnly
[8] => Set-Cookie: t=b9e8101e83a7e0f0cafdd6296abb05a4; Domain=.alimama.com; Expires=Tue, 18-Jul-2023 02:04:51 GMT; Path=/
[9] => Set-Cookie: v=0; Domain=.alimama.com; Path=/
[10] => Content-Language: zh-CN
[11] => Expires: Fri, 18 Oct 2013 01:24:51 GMT
[12] => Cache-Control: max-age=0
)
这几个 cookie 你也没有提交
CURLOPT_COOKIEFILE 是发送 cookie 文件(通常是上面取回的)