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);//就有数据了注意空格那些都要和代码里的一致