phpcms無法采集的解決方法?這個(gè)問題可能是我們?nèi)粘W(xué)習(xí)或工作經(jīng)常見到的。希望通過這個(gè)問題能讓你收獲頗深。下面是小編給大家?guī)淼膮⒖純?nèi)容,讓我們一起來看看吧!
創(chuàng)新互聯(lián)是專業(yè)的開州網(wǎng)站建設(shè)公司,開州接單;提供成都網(wǎng)站建設(shè)、網(wǎng)站制作,網(wǎng)頁設(shè)計(jì),網(wǎng)站設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行開州網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來合作!
phpcms無法采集怎么辦?
無法采集https的網(wǎng)站內(nèi)容主要是https不支持file_get_contents獲取內(nèi)容,所以可以考慮采用curl的方式獲取。(需要開啟curl,可以在pathinfo里邊查看)
(1)打開phpcms\modules\collection\classes\collection.class.php
在類里邊添加新函數(shù):
protected static function curl_request($url){ if (!function_exists('curl_init')) { throw new Exception('server not install curl'); } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_HEADER,0); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);//禁止調(diào)用時(shí)就輸出獲取到的數(shù)據(jù) 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; }
(2)找到函數(shù)function get_htm把該函數(shù)
protected static function get_html($url, &$config) { if (!empty($url) && $html = @file_get_contents($url)) { if ($syscharset != $config['sourcecharset'] && $config['sourcetype'] != 4) { $html = iconv($config['sourcecharset'], CHARSET.'//TRANSLIT//IGNORE', $html); } return $html; } else { return false; } }
改成
protected static function get_html($url, &$config) { if(substr(trim($url),0, 5) == "https"){ $html = @self::curl_request($url); }else{ $html = @file_get_contents($url); } if (!empty($url) && $html) { if ($syscharset != $config['sourcecharset'] && $config['sourcetype'] != 4) { $html = iconv($config['sourcecharset'], CHARSET.'//TRANSLIT//IGNORE', $html); } return $html; } else { return false; } }
然后保存即可獲取,測試結(jié)果
不知道是否還有其他bug,歡迎留言反饋!
感謝各位的閱讀!看完上述內(nèi)容,你們對phpcms無法采集的解決方法大概了解了嗎?希望文章內(nèi)容對大家有所幫助。如果想了解更多相關(guān)文章內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。
本文標(biāo)題:phpcms無法采集的解決方法
網(wǎng)址分享:http://aaarwkj.com/article8/gjogip.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供虛擬主機(jī)、電子商務(wù)、做網(wǎng)站、品牌網(wǎng)站設(shè)計(jì)、外貿(mào)網(wǎng)站建設(shè)、企業(yè)建站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)