一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

PHP獲取163、gmail、126等郵箱聯系人地址【已測試2009.10.10】

在網上找了一些,大部分都已經失效,為此我重新整理了一下;特別放出126的代碼,163是比較容易抓取的;126有點變態多了一次跳轉,比較麻煩
復制代碼 代碼如下:
<?php
/**
* @file class.126http.php
* 獲得126郵箱通訊錄列表
* @author jvones<jvones@gmail.com> http://www.jvones.com/blog
* @date 2009-09-26
**/
class http126
{
private function login($username, $password)
{
//第一步:初步登陸
$cookies = array();
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_URL, "https://reg.163.com/logins.jsp?type=1&product=mail126&url=http://entry.mail.126.com/cgi/ntesdoor?hid%3D10010102%26lightweight%3D1%26verifycookie%3D1%26language%3D0%26style%3D-1");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "username=".$username."@126.com&password=".$password);
curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIEJAR);
curl_setopt($ch,CURLOPT_HEADER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, TIMEOUT);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$str = curl_exec($ch);
//file_put_contents('./126result.txt', $str);
curl_close($ch);
//獲取redirect_url跳轉地址,可以從126result.txt中查看,通過正則在$str返回流中匹配該地址
preg_match("/replace/(/"(.*?)/"/)/;/", $str, $mtitle);
$_url1 = $mtitle[1];
//file_put_contents('./126resulturl.txt', $redirect_url);
//第二步:再次跳轉到到上面$_url1
$ch = curl_init($_url1);
curl_setopt($ch, CURLOPT_TIMEOUT, TIMEOUT);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_COOKIEFILE,COOKIEJAR);
curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIEJAR);
curl_setopt($ch,CURLOPT_HEADER,1);
$str2 = curl_exec($ch);
curl_close($ch);
if (strpos($contents, "安全退出") !== false)
{
return 0;
}
return 1;
}
/**
* 獲取郵箱通訊錄-地址
* @param $user
* @param $password
* @param $result
* @return array
*/
public function getAddressList($username, $password)
{
if (!$this->login($username, $password))
{
return 0;
}
$header = $this->_getheader($username);
if (!$header['sid'])
{
return 0;
}
//測試找出sid(很重要)和host
//file_put_contents('./host.txt', $header['host']);
//file_put_contents('./sid.txt', $header['sid']);
//開始進入模擬抓取
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://".$header['host']."/a/s?sid=".$header['sid']."&func=global:sequential");
curl_setopt($ch, CURLOPT_COOKIEFILE, COOKIEJAR);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/xml"));
$str = "<?xml version=/"1.0/"?><object><array name=/"items/"><object><string name=/"func/">pab:searchContacts</string><object name=/"var/"><array name=/"order/"><object><string name=/"field/">FN</string><boolean name=/"ignoreCase/">true</boolean></object></array></object></object><object><string name=/"func/">user:getSignatures</string></object><object><string name=/"func/">pab:getAllGroups</string></object></array></object>";
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $str);
curl_setopt($ch, CURLOPT_TIMEOUT, TIMEOUT);
ob_start();
curl_exec($ch);
$contents = ob_get_contents();
ob_end_clean();
curl_close($ch);
//get mail list from the page information username && emailaddress
preg_match_all("/<string/s*name=/"EMAIL;PREF/">(.*)<//string>/Umsi",$contents,$mails);
preg_match_all("/<string/s*name=/"FN/">(.*)<//string>/Umsi",$contents,$names);
$users = array();
foreach($names[1] as $k=>$user)
{
//$user = iconv($user,'utf-8','gb2312');
$users[$mails[1][$k]] = $user;
}
if (!$users)
{
return '您的郵箱中尚未有聯系人';
}
return $users;
}
/**
* Get Header info
*/
private function _getheader($username)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://entry.mail.126.com/cgi/ntesdoor?hid=10010102&lightweight=1&verifycookie=1&language=0&style=-1&username=".$username."@126.com");
curl_setopt($ch, CURLOPT_COOKIEFILE, COOKIEJAR); //當前使用的cookie
curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIEJAR); //服務器返回的新cookie
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
$content=curl_exec($ch);
preg_match_all('/Location:/s*(.*?)/r/n/i',$content,$regs);
$refer = $regs[1][0];
preg_match_all('/http/:////(.*?)///i',$refer,$regs);
$host = $regs[1][0];
preg_match_all("/sid=(.*)/i",$refer,$regs);
$sid = $regs[1][0];
curl_close($ch);
return array('sid'=>$sid,'refer'=>$refer,'host'=>$host);
}
}
?>

點擊查看原圖 

php技術PHP獲取163、gmail、126等郵箱聯系人地址【已測試2009.10.10】,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 激情婷婷| 久久窝窝国产精品午夜看15 | 日韩视频第一页 | 日韩亚洲国产综合久久久 | 亚洲第一区视频 | 成人欧美视频免费看黄黄 | 日本一区二区视频 | 在线色网址 | 色爱区综合 | 精品国产福利第一区二区三区 | 一级爱做片免费观看久久 | 五月天婷婷久久 | 亚洲国产韩国一区二区 | 国产色婷婷精品综合在线 | 日韩激情中文字幕 | 加勒比在线 | 91在线国产观看 | 第一页综合| 亚洲美女免费视频 | 午夜在线日韩免费精品福利 | 色综合久久婷婷天天 | 成人黄色小视频在线观看 | 亚洲第一se情网站 | www.婷婷| 天天舔 | 狼人综合伊人 | 在线播放国产精品 | 在线观看激情 | 亚洲综合激情另类小说区 | 色哟哟哟 | 欧洲色播| 国产精品麻豆一区二区 | 色综合久久88一加勒比 | 激情视频网站 | 国语对白精品视频在线观看 | www.日本高清 | 五月天色视频 | 亚洲日本va中文字幕婷婷 | 四虎国产精品永久地址99新强 | 四虎永久在线精品视频播放 | 色视频在线观看网站 |