为何模拟浏览器的cookie,或者登陆,必须要再别的url抓取cookie,然后再模拟cookie发出:
curl:
把curl_setopt($ch,CURLOPT_HEADER,false)就行了。
需要展现cookie:
//打开cookie显示!!!
curl:
把curl_setopt($ch,CURLOPT_HEADER,false)就行了。
需要展现cookie:
curl_setopt ( $ch_curl, CURLOPT_HEADER, true);
//打开cookie显示!!!
function curl_post($url, $content)
{
//echo $url;
//echo $content;
$str_url = $url;
$str_post_data = $content;
$ch_curl = curl_init ();
curl_setopt ( $ch_curl, CURLOPT_TIMEOUT, 3 );
curl_setopt ( $ch_curl, CURLOPT_HEADER, true);
curl_setopt ( $ch_curl, CURLOPT_POST, 1 );
curl_setopt ( $ch_curl, CURLOPT_RETURNTRANSFER, true );
curl_setopt ( $ch_curl, CURLOPT_URL, $str_url );
curl_setopt ( $ch_curl, CURLOPT_POSTFIELDS, $str_post_data );
$str_return = curl_exec ( $ch_curl );
if ($str_return === false)
return false;
curl_close ( $ch_curl );
return $str_return;
}
{
//echo $url;
//echo $content;
$str_url = $url;
$str_post_data = $content;
$ch_curl = curl_init ();
curl_setopt ( $ch_curl, CURLOPT_TIMEOUT, 3 );
curl_setopt ( $ch_curl, CURLOPT_HEADER, true);
curl_setopt ( $ch_curl, CURLOPT_POST, 1 );
curl_setopt ( $ch_curl, CURLOPT_RETURNTRANSFER, true );
curl_setopt ( $ch_curl, CURLOPT_URL, $str_url );
curl_setopt ( $ch_curl, CURLOPT_POSTFIELDS, $str_post_data );
$str_return = curl_exec ( $ch_curl );
if ($str_return === false)
return false;
curl_close ( $ch_curl );
return $str_return;
}
作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:http://jackxiang.com/post/3927/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!
评论列表