$response = "https://faculty.xidian.edu.cn/system/resource/tsites/tsitesencrypt.jsp?id=_tsites_encryp_tsteacher_tsemail&content=a7da9f4e0712b1c3626d8439f202e43f6691c82013ba38566aef822c1325d2789ec60e565088f4f967d264d6e6f6231a69c3356def42082aeb9e969cc8ae996f9bf727f708cfff958a1d61e56e4edce659242cb0ceed0841bc36124341b0429c21cdf3130f623e71bfd80f03ad0179634b081f4ba15d74dbf1d02e2e1815795d&mode=8"; echo curl($response); function curl($url){ $ch = curl_init(); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5000); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array('User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/600.1.3 (KHTML, like Gecko) Version/8.0 Mobile/12A4345d Safari/600.1.4')); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); $contents = curl_exec($ch); curl_close($ch);//關閉一打開的會話 return $contents; }
遠程採集一個https頁面上的郵箱,死活採集不到,後來發現用上面的這個方法是能夠採集到的,須要注意的是,其中curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);這兩段代碼是關鍵,沒有這個就會提示ssl驗證有問題;curl