日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > php >内容正文

php

curl php 百度,phpcurl模拟登录百度首页

發(fā)布時(shí)間:2025/3/20 php 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 curl php 百度,phpcurl模拟登录百度首页 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

代碼如下:

*/$post_fields = array();$post_fields = preg_data($contents,'aid',$post_fields);$post_fields = preg_data($contents,'isphone',$post_fields);$post_fields['mem_pass'] = 'on'; //post 數(shù)據(jù)數(shù)組 記住我的登錄狀態(tài)$post_fields = preg_data($contents,'more_param',$post_fields);$post_fields = preg_data($contents,'need_coin',$post_fields);$post_fields = preg_data($contents,'need_pay',$post_fields);$post_fields = preg_data($contents,'next_target',$post_fields);$post_fields['password'] = 'password'; //post 數(shù)據(jù)數(shù)組 記住我的登錄狀態(tài)$post_fields = preg_data($contents,'pay_method',$post_fields);$post_fields = preg_data($contents,'psp_tt',$post_fields);$post_fields = preg_data($contents,'return_method',$post_fields);$post_fields = preg_data($contents,'return_type',$post_fields);$post_fields = preg_data2($contents,'safeflg',$post_fields);$post_fields = preg_data($contents,'skip_ok',$post_fields);$post_fields = preg_data($contents,'tpl',$post_fields);$post_fields = preg_data($contents,'tpl_ok',$post_fields);$post_fields['u'] = 'http://www.baidu.com/';$post_fields['username'] = 'username'; //post 數(shù)據(jù)數(shù)組 記住我的登錄狀態(tài)$post_fields['verifycode'] = '';$ch = curl_init();curl_setopt ($ch, CURLOPT_URL, $url);curl_setopt ($ch, CURLOPT_HEADER, 0);curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt ($ch, CURLOPT_POST, 1);curl_setopt ($ch, CURLOPT_POSTFIELDS, $post_fields);curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookdir);curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)");curl_setopt ($ch, CURLOPT_REFERER, "https://passport.baidu.com/?login&tpl=mn");curl_exec($ch);curl_close($ch);$url = "http://www.baidu.com/";$ch = curl_init();curl_setopt($ch, CURLOPT_URL, $url);curl_setopt($ch, CURLOPT_HEADER, 0);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_COOKIEFILE, $cookdir);curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)");curl_setopt ($ch, CURLOPT_REFERER, "http://www.baidu.com/n");$contents = curl_exec($ch);print_r($contents);die;curl_close($ch);exit;function preg_data($source,$chr,$array){preg_match('//i', $source, $matches);if(!empty($matches)) { $a = $matches[1];} else { die('Not found the '.$chr.'.');}$array[$chr]=$a;return $array;}function preg_data2($source,$chr,$array){preg_match('//i', $source, $matches);if(!empty($matches)) { $a = $matches[1];} else { die('Not found the '.$chr.'.');}$array[$chr]=$a;return $array;}?>

現(xiàn)在是無(wú)法訪問(wèn)到登錄后的頁(yè)面 高手指教

回復(fù)討論(解決方案)

可能是網(wǎng)址轉(zhuǎn)向了

CURLOPT_FOLLOWLOCATION設(shè)置這個(gè)參數(shù)為TRUE試試看

CURLOPT_FOLLOWLOCATION設(shè)置這個(gè)參數(shù)為TRUE試試看

這個(gè)貌似不行啊

看不懂咋回事!!!

之前已經(jīng)寫了python和c#的版本的了。

等我抽空,再弄個(gè)php版本的,模擬登錄百度,給你看看。

樓主問(wèn)題解決了么

本條技術(shù)文章來(lái)源于互聯(lián)網(wǎng),如果無(wú)意侵犯您的權(quán)益請(qǐng)點(diǎn)擊此處反饋版權(quán)投訴

本文系統(tǒng)來(lái)源:php中文網(wǎng)

總結(jié)

以上是生活随笔為你收集整理的curl php 百度,phpcurl模拟登录百度首页的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。