欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php curl 登錄163郵箱并抓取郵箱好友列表的代碼(經(jīng)測(cè)試)

 更新時(shí)間:2011年04月07日 18:17:39   作者:  
PHP模擬登陸獲取163郵箱聯(lián)系人的實(shí)現(xiàn)代碼,需要的朋友可以參考下。
CURL技術(shù)說白了就是模擬瀏覽器的動(dòng)作實(shí)現(xiàn)頁(yè)面抓取或表單提交,通過此技術(shù)可以實(shí)現(xiàn)許多有去的功能。
復(fù)制代碼 代碼如下:

<?php
error_reporting(0);
//郵箱用戶名(不帶@163.com后綴的)
$user = 'papatata_test';
//郵箱密碼
$pass = '000000';
//目標(biāo)郵箱
//$mail_addr = uenucom@163.com';
//登陸
$url = 'http://reg.163.com/logins.jsp?type=1&url=http://entry.mail.163.com/coremail/fcg/ntesdoor2?lightweight%3D1%26verifycookie%3D1%26language%3D-1%26style%3D-1';
$ch = curl_init($url);
//創(chuàng)建一個(gè)用于存放cookie信息的臨時(shí)文件
$cookie = tempnam('.','~');
$referer_login = 'http://mail.163.com';
//返回結(jié)果存放在變量中,而不是默認(rèn)的直接輸出
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_REFERER, $referer_login);
$fields_post = array(
'username'=> $user,
'password'=> $pass,
'verifycookie'=>1,
'style'=>-1,
'product'=> 'mail163',
'selType'=>-1,
'secure'=>'on'
);
$headers_login = array(
'User-Agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9) Gecko/2008052906 Firefox/3.0',
'Referer' => 'http://www.163.com'
);
$fields_string = '';
foreach($fields_post as $key => $value)
{
$fields_string .= $key . '=' . $value . '&';
}
$fields_string = rtrim($fields_string , '&');
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
//關(guān)閉連接時(shí),將服務(wù)器端返回的cookie保存在以下文件中
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers_login);
curl_setopt($ch, CURLOPT_POST, count($fields));
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
$result= curl_exec($ch);
curl_close($ch);
//跳轉(zhuǎn)
$url='http://entry.mail.163.com/coremail/fcg/ntesdoor2?lightweight=1&verifycookie=1&language=-1&style=-1&username=loki_wuxi';
$ch = curl_init($url);
$headers = array(
'User-Agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9) Gecko/2008052906 Firefox/3.0'
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
//將之前保存的cookie信息,一起發(fā)送到服務(wù)器端
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
$result = curl_exec($ch);
curl_close($ch);
//取得sid
preg_match('/sid=[^\"].*/', $result, $location);
$sid = substr($location[0], 4, -1);
//file_put_contents('./result.txt', $sid);
//通訊錄地址
$url='http://g4a30.mail.163.com/jy3/address/addrlist.jsp?sid='.$sid.'&gid=all';
$ch = curl_init($url);
$headers = array(
'User-Agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9) Gecko/2008052906 Firefox/3.0'
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
$result = curl_exec($ch);
curl_close($ch);
//file_put_contents('./result.txt', $result);
unlink($cookie);
//開始抓取內(nèi)容
preg_match_all('/<td class="Ibx_Td_addrName"><a[^>]*>(.*?)<\/a><\/td><td class="Ibx_Td_addrEmail"><a[^>]*>(.*?)<\/a><\/td>/i', $result,$infos,PREG_SET_ORDER);
//1:姓名2:郵箱
print_r($infos);
?>

相關(guān)文章

  • 基于laravel制作APP接口(API)

    基于laravel制作APP接口(API)

    這篇文章主要介紹了基于laravel制作APP接口(API)的相關(guān)資料,需要的朋友可以參考下
    2016-03-03
  • PHP+mysql實(shí)現(xiàn)的三級(jí)聯(lián)動(dòng)菜單功能示例

    PHP+mysql實(shí)現(xiàn)的三級(jí)聯(lián)動(dòng)菜單功能示例

    這篇文章主要介紹了PHP+mysql實(shí)現(xiàn)的三級(jí)聯(lián)動(dòng)菜單功能,涉及mysql數(shù)據(jù)庫(kù)創(chuàng)建、數(shù)據(jù)添加及php讀取mysql、創(chuàng)建聯(lián)動(dòng)菜單相關(guān)操作技巧,需要的朋友可以參考下
    2019-02-02
  • php+AJAX傳送中文會(huì)導(dǎo)致亂碼的問題的解決方法

    php+AJAX傳送中文會(huì)導(dǎo)致亂碼的問題的解決方法

    關(guān)于在AJAX中GET回的ResponseText中文亂碼的最簡(jiǎn)解決辦法
    2008-09-09
  • PHP 反射(Reflection)使用實(shí)例

    PHP 反射(Reflection)使用實(shí)例

    這篇文章主要介紹了PHP 反射(Reflection)使用實(shí)例,本文講解了ReflectionClass、ReflectionExtension、 ReflectionFunction、ReflectionMethod、ReflectionObject、ReflectionParameter等類的使用實(shí)例,需要的朋友可以參考下
    2015-05-05
  • PHP實(shí)現(xiàn)獲取毫秒時(shí)間戳的方法【使用microtime()函數(shù)】

    PHP實(shí)現(xiàn)獲取毫秒時(shí)間戳的方法【使用microtime()函數(shù)】

    這篇文章主要介紹了PHP實(shí)現(xiàn)獲取毫秒時(shí)間戳的方法,結(jié)合實(shí)例形式分析了php使用microtime()函數(shù)獲取、轉(zhuǎn)換毫秒級(jí)時(shí)間戳的相關(guān)操作技巧,需要的朋友可以參考下
    2019-03-03
  • PHP實(shí)現(xiàn)將幾張照片拼接到一起的合成圖片功能【便于整體打印輸出】

    PHP實(shí)現(xiàn)將幾張照片拼接到一起的合成圖片功能【便于整體打印輸出】

    這篇文章主要介紹了PHP實(shí)現(xiàn)將幾張照片拼接到一起的合成圖片功能,可實(shí)現(xiàn)多張圖片的合并,便于整體打印輸出.涉及php字符串、數(shù)組的遍歷、排序及圖片合成、裁剪、縮放等相關(guān)操作技巧,需要的朋友可以參考下
    2017-11-11
  • 合格的PHP程序員必備技能

    合格的PHP程序員必備技能

    要想成為一個(gè)合格的PHP程序員需要掌握許多技能,這篇文章就向大家介紹了一個(gè)合格的PHP程序員必備技能,想要真正了解php程序的朋友一定仔細(xì)閱讀,判斷自己具備多少個(gè)技能。
    2015-11-11
  • PHP緩沖區(qū)用法總結(jié)

    PHP緩沖區(qū)用法總結(jié)

    這篇文章主要介紹了PHP緩沖區(qū)用法,結(jié)合實(shí)例形式總結(jié)分析了PHP緩沖區(qū)的功能、使用技巧與相關(guān)注意事項(xiàng),需要的朋友可以參考下
    2016-02-02
  • jQuery+php實(shí)現(xiàn)ajax文件即時(shí)上傳的詳解

    jQuery+php實(shí)現(xiàn)ajax文件即時(shí)上傳的詳解

    本篇文章是對(duì)jQuery+php實(shí)現(xiàn)ajax文件即時(shí)上傳的方法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
    2013-06-06
  • PHP設(shè)計(jì)模式之中介者模式淺析

    PHP設(shè)計(jì)模式之中介者模式淺析

    這篇文章主要介紹了PHP設(shè)計(jì)模式之中介者模式,中介者模式(Mediator Pattern)是一種常用的設(shè)計(jì)模式,用于解決各個(gè)對(duì)象之間的復(fù)雜依賴關(guān)系,使得各個(gè)對(duì)象之間可以獨(dú)立地改變自己的行為,而不需要與其他對(duì)象發(fā)生直接的交互
    2023-04-04

最新評(píng)論