PHP取得163、gmail、126等郵件信箱聯絡人地址

WBOY
發布: 2016-07-29 08:40:56
原創
1997 人瀏覽過

在網路上找了一些,大部分都已經失效,為此我重新整理了一下;特別放出126的程式碼,163是比較容易抓取的;126有點變態多了一次跳轉,比較麻煩

複製程式碼 程式碼如下:


/**
* @file class.126http.php
* 取得126信箱通訊錄清單
* @author jvones 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($chURL, CUR. "https://reg.163.com/logins.jsp?type=1&product=mail126&url=http://entry.mail.126.com/cgi/ntesdoor?hid%3D10010102%26lightweight%3D1%26verifycookie%3D1%26gulanage %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_NME, CURLOc/ME, c , CURLOPT_RETURNTRANSFER, true);
$str = curl_exec($ch);
//file_put_contents('./126result.., $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_RETURNTRANURER, 0UR30,30003(cURL); COOKIEJAR);
curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIEJAR);
curl_setopt($ch,CURLOPT_HEADER,1);
$str2 = curl_exec($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 = "pab:searchContactsFNtrueuser:getSignatures pab:getAllGroups";
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $str);
curl_setopt($ch, CURLOPT_TIMEOUT, TIMEOUT);
ob_start();
curl_exec($ch);
$contents = _get); >ob_end_clean();
curl_close($ch);
//get mail list from the page information username && emailaddress
preg_match_all("/(>preg_match_all("/(* )/Umsi",$contents,$mails);
preg_match_all("/(.*)/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;
}
/**
* 取得標題資訊
*/
私有函數_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, CURFI/CIEFIAR, CIEFIAR, CIEFIAR, CIEFIAR, CIEFIAR, CIEFIAR, CIEFIAR, CIEFIAR, CIEFIAR, CIEFIAR, CIEFIAR, CIEFIAR, CIEFIAR, CIEFIAR, CIEFIAR, CIEFIAR, CIEFIAR, CIEFIAR, CIEFIAR, CIEFIAR, CIEFIAR,CIEFIAR, CIEFIAR), CURFIAR, CIEFIAR, CIEFIAR), CURMFIAR, CIEFIAR)」 ); //目前使用的cookie
curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIEJAR); // 傳回伺服器的新cookie
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); , true);
curl_setopt($ch, CURLOPT_NOBODY, true);
$c
preg_match_all('/位置:s*(.*?)rn/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);
回傳陣列('sid'=>$sid,'refer'=>$refer,'host'=>$host);
}
}
?>


 PHP获取163、gmail、126等邮箱联系人地址  以上就介紹了PHP取得163、gmail、126等郵件信箱地址,包括了方面的內容,希望對PHP教學有興趣的朋友有幫助。

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!