1.file_get_contents沒法抓取https安全協議的網站php
改用curl獲取數據html
function file_get_contents_by_curl($url){ $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_FOLLOWLOCATION,1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,false); $result = curl_exec($ch); curl_close($ch);return $result;}
require('phpQuery.php');
$content = file_get_contents_by_curl($url);
$html = phpQuery::newDocumentHTML($content);
2.iconv特殊字符沒法進行轉換安全
改進方式:mb_convert_encoding($str,'GBK','utf-8');curl