php獲取標題
1. php的採集程序,怎麼截取網頁中的鏈接及標題
首先用fopen或者file_get_contents或者curl獲取整個網頁的內容
然後使用正則表達式來獲取網頁的特定內容,也可以使用其他方法,具體你搜索下吧.
也可以使用Document Object Model ,用法自己去搜索吧,這里重復感覺沒必要
提醒:最好是將鏈接和標題的區域從整個網頁提取出來,到時候更容易處理 可以使用substr來提取
2. think php 如何獲取<head>中的<title> 在瀏覽器中標題欄顯示
直接把標本庫換成變數,你想改成什麼,只需要在php頁面有titile這個變數傳遞過來就ok了
3. phpcms中如何獲取欄目標題
{$CATEGORY[$r[catid]][catname]}這個是欄目的標題
{if $showcatname}<a href="{$CATEGORY[$r[catid]][url]}" class="catname">[{$CATEGORY[$r[catid]][catname]}]</a>{/if}<a target="{$target}" href="{$r[url]}">{str_cut($r[title], $titlelen)}</a>
這個才是id標題
{date('Y-m-d', $r[inputtime])}這個是時間
4. PHP框架獲取title標題
樓主 不明白你的意思了 又要用include 又要只有一個頁面,如果用include 那就必會有兩個文件了!!!
如果只要一個頁面:
這樣來:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標題文檔</title>
</head>
<body>
<div><a href="a.php?type=1">導航一</a> <a href="a.php?type=2">導航二</a></div>
<?php if($_GET[type]==1){?>
<div>點擊導航一 展示的頁面</div>
<?php }else if($_GET[type]==2){?>
<div>點擊導航二 展示的頁面</div>
<?php } ?>
</body>
</html>
5. php sql怎麼獲取標題字元串值等於固定長度的數據
您好,很榮幸與您溝通。
select * from proct where char_length(title)=3; 星號就是你的表中的欄位名。*號是獲取所有的數據這樣佔用的欄位會比較大。最好是你自己選一個欄位進行查詢。
祝你一切順利。
6. php怎麼獲得當前頁面的標題
一、推薦方法 CURL獲取
<?php
$c = curl_init();
$url = 'www.jb51.net';
curl_setopt($c, CURLOPT_URL, $url);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($c);
curl_close($c);
$pos = strpos($data,'utf-8');
if($pos===false){$data = iconv("gbk","utf-8",$data);}
preg_match("/<title>(.*)<\/title>/i",$data, $title);
echo $title[1];
?>
二、使用file()函數
<?php
$lines_array = file('http://www.jb51.net/');
$lines_string = implode('', $lines_array);
$pos = strpos($lines_string,'utf-8');
if($pos===false){$lines_string = iconv("gbk","utf-8",$lines_string);}
eregi("<title>(.*)</title>", $lines_string, $title);
echo $title[1];
?>
三、使用file_get_contents
<?php
$content=file_get_contents("http://www.jb51.net/");
$pos = strpos($content,'utf-8');
if($pos===false){$content = iconv("gbk","utf-8",$content);}
$postb=strpos($content,'<title>')+7;
$poste=strpos($content,'</title>');
$length=$poste-$postb;
echo substr($content,$postb,$length);
?>
7. php正則提取網頁源碼中的 商品標題
<?php
$str='<aclass="Seta"href="/photos/838699888/albums/39620275/"title="耐克科比ZK6代(最高版本)黑綠桔40-46">耐克科比ZK6代(最高版本)黑綠桔40-46</a>';
preg_match_all('/<as+class="Seta"s+href="[^"]*"s+title=".*?">(.*?)</a>/is',$str,$matched);
print_r($matched[1]);
exit;
8. php獲取指定網站的文章標題以及連接
寫一個正則匹配就可以了
$html='<li>..................</li>';
preg_match_all('/<li><ahref="(.*)">(.*)</a><spanstyle="color:#F00;">(.*)</span></li>/Ui',$html,$data);
print_R($data);//就有數據了注意空格那些都要和代碼里的一致