//$url='http://www.ttphp.com;

$pageinfo = array(); $pageinfo[content_type] = ''; $pageinfo[charset] = ''; " /> 人妻超级精品碰碰在线97视频,青春草久久,日韩在线中文字幕无码

天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

php獲取網(wǎng)頁(yè)標(biāo)題和內(nèi)容函數(shù)(不包含html標(biāo)簽)

復(fù)制代碼 代碼如下:
function getPageContent($url) {  

        //$url='http://www.ttphp.com;  

        $pageinfo = array();  
        $pageinfo[content_type] = '';  
        $pageinfo[charset] = '';  
        $pageinfo[title] = '';  
        $pageinfo[description] = '';  
        $pageinfo[keywords] = '';  
        $pageinfo[body] = '';  
        $pageinfo['httpcode'] = 200;  
        $pageinfo['all'] = '';   

        $ch = curl_init();  
        curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");  
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);  
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);  
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0);  
        curl_setopt($ch, CURLOPT_TIMEOUT, 8);  
        curl_setopt($ch, CURLOPT_FILETIME, 1);  
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);  
        //curl_setopt($ch, CURLOPT_HEADER, 1);        
        curl_setopt($ch, CURLOPT_URL,$url);  

        $curl_start = microtime(true);  
        $store = curl_exec ($ch);  

        $curl_time = microtime(true) - $curl_start;  
        if( curl_error($ch) ) {  
            $pageinfo['httpcode'] = 505;  //gate way error  
            echo 'Curl error: ' . curl_error($ch) ."/n";  
            return $pageinfo;  
        }  

        //print_r(curl_getinfo($ch));  
        $pageinfo['httpcode'] = curl_getinfo($ch,CURLINFO_HTTP_CODE);  
        //echo curl_getinfo($ch,CURLINFO_CONTENT_TYPE)."/n";  
        $pageinfo[content_type] = curl_getinfo($ch,CURLINFO_CONTENT_TYPE);  
        if(intval($pageinfo['httpcode']) <> 200 or !preg_match('@text/html@',curl_getinfo($ch,CURLINFO_CONTENT_TYPE) )   ) {  
                //print_r(curl_getinfo($ch) );  
                //exit;  
                return $pageinfo;  
        }  
        preg_match('/charset=([^/s/n/r]+)/i',curl_getinfo($ch,CURLINFO_CONTENT_TYPE),$matches); //從header 里取charset  
        if( trim($matches[1]) ) {  
            $pageinfo[charset] = trim($matches[1]);  
        }  
        //echo $pageinfo[charset];  
        //exit;  
        curl_close ($ch);  
        //echo $store;  

 
        //remove Javascript  
        $store = preg_replace("/<mce:script.*><!--
(.*)<//script>/smUi",'',$store);  
        //remove link   
        $store = preg_replace("/<link/s+[^>]+>/smUi",'',$store);  
        //remove <!--  -->  
        $store = preg_replace("/<!--.*-->/smUi",'',$store);  
        //remove <style  </<style>  
        $store = preg_replace("/<style.*>(.*)<//style>/smUi",'',$store);  
        //remove 中文空格  
        $store = preg_replace("/ /",'',$store);  
        //remove 標(biāo)點(diǎn)符號(hào)  
        //$store = preg_replace("/[/~`!@#$%^&*()_/-+={}|/[/]//;':"/</>/?/,/.//]/",'',$store);  

          
        //preg_match("/<head.*>(.*)<//head>/smUi",$store, $matches);  
        //$head = $matches[1];  
        //echo $head. "/n";  

        //charset  
        if($pageinfo[charset] == '' ) { 
            preg_match('@<meta.+charset=([/w/-]+)[^>]*>@i',$store,$matches); 
            $pageinfo[charset] = trim($matches[1]); 
        } 
        //desctiption 
        preg_match('@<meta/s+name=/"*description/"*/s+content/s*=/s*([^/>]+)/*>@i',$store,$matches); 
        //print_r($matches); 
        $desc = trim($matches[1]); 
        $pageinfo[description] = str_replace("/"", '',$desc); 

 
        preg_match('@<meta/s+name=/"*keywords/"*/s+content/s*=/s*([^/>]+)/*>@i',$store,$matches); 
        //print_r($matches); 
        $keywords = trim($matches[1]); 
        $pageinfo[keywords] = str_replace("/"", '',$keywords); 

         
        preg_match("/<title>(.*)<//title>/smUi",$store, $matches); 
        $pageinfo[title] = trim($matches[1]); 

        preg_match("/<body.*>(.*)<//body>/smUi",$store, $matches); 
        $pageinfo[body] = addslashes( replaceHtmlAndJs($matches[1]) ) ; 
        $pageinfo['all'] = addslashes( replaceHtmlAndJs($store) ) ; 

        //echo "charset = " . $pageinfo[charset] . "/n"; 

        //print_r($pageinfo); 
        //exit; 

         
        return $pageinfo; 



/** 
 * 去掉所有的HTML標(biāo)記和JavaScript標(biāo)記 
 */ 
function replaceHtmlAndJs($document)  
{  
         $document = trim($document);  
         if (strlen($document) <= 0)  
         {  
          return $document;  
         }  
         $search = array (        
                                            "'<script[^>]*?>.*?
// --></mce:script>'si",  // 去掉 Javascript  
                          "'<[///!]*?[^<>]*?>'si",          // 去掉 HTML 標(biāo)記  
                          "'[/r/n/s+]'",                // 去掉空白字符  
                          "'&(/w+);'i"              // 替換 HTML 實(shí)體  
                         );                    // 作為 php 代碼運(yùn)行  

         $replace = array ( "", "", "", ""  );  

         return @preg_replace ($search, $replace, $document);  




使用例子

復(fù)制代碼 代碼如下:
$a = getPageContent(www.ttphp.com);  
print_r($a);

php技術(shù)php獲取網(wǎng)頁(yè)標(biāo)題和內(nèi)容函數(shù)(不包含html標(biāo)簽),轉(zhuǎn)載需保留來(lái)源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 精品国产午夜肉伦伦影院 | 成年人视频在线免费 | 色戒西瓜视频 | 婷婷激情综合色五月久久竹菊影视 | 交换娇妻呻吟声不停中文字幕 | 女教师二十三岁 | 国产在线视精品在亚洲 | 阿v天堂2017在无码 | 中文字幕亚洲男人的天堂网络 | 久久爽狠狠添AV激情五月 | 乳巨揉みま痴汉电车中文字幕动漫 | a级毛片黄免费a级毛片 | 边做边爱免费视频 | 快播金瓶梅 | 欧美 日韩 亚洲 在线 | 在线观看免费国产成人软件 | 久久热r在线视频精品 | 寂寞夜晚视频高清观看免费 | 人人碰在线视频 | 被同桌摸出水来了好爽的视频 | 99视频精品全部免费免费观 | 少女开女包www| 亚洲国产在线视频中文字 | 老师给美女同学开嫩苞 | 亚洲欧洲日本无在线码播放 | 国产人妻777人伦精品HD | 亚洲欧美日韩高清中文在线 | 国产亚洲精品V在线观看一 国产亚洲精品a在线观看app | 不卡人妻无码AV中文系列APP | 成年无码av片| 国模啪啪久久久久久久 | 日韩精品在线观看免费 | 久久涩视频 | 亚洲字幕久久 | 日本少妇无码精品12P | 色窝窝亚洲AV在线观看 | bt天堂午夜国产精品 | 国产亚洲精品网站在线视频 | x8国产精品视频 | bl撅高扒开臀缝哦 | 永久午夜福利视频一区在线观看 |