首页 > 编程知识 正文

php搜索网页标题(php标签大全)

时间:2023-11-29 12:18:45 阅读:310083 作者:MHQY

本文目录一览:

  • 1、php怎么获得当前页面的标题
  • 2、php站内搜索怎么做
  • 3、求一个简易的php爬虫提取网页的title
  • 4、php如何通过地址去获取一个网页的标题title里面的内容
  • 5、php获取指定网站的文章标题以及连接

php怎么获得当前页面的标题

一、推荐方法 CURL获取

?php

$c = curl_init();

$url = '';

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('');

$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("");

$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);

?

php站内搜索怎么做

站内搜索是一种使用关键字来搜索文章标题的功能。

PHP的站内搜索可以使用SELECT和LIKE语句来对文章的标题进行过滤选择,将需要的数据筛选出来。 如果有多个筛选可以使用AND语句连接起来进行多条语句筛选。 如果希望是能搜索到全站所有的数据,一般在数据库设计之初最好就是把所有数据放一个表,然后通过扩展表的方式进行数据扩展!具体方法可以参考ONETHINK的设计模式。

具体搜索方法: SELECT * FROM 表名 WHERE 字段 LIKE '%关键字%'

求一个简易的php爬虫提取网页的title

header("Content-Type: text/html; charset=gbk");

$url = "";

$fcontents = file_get_contents($url);

if (ereg("title(.*)/title", $fcontents, $regs)){echo "ok";}else{echo "error";}

echo "br";

print_r($regs);

php如何通过地址去获取一个网页的标题title里面的内容

sybase_connect连上数据库。

语法: int sybase_connect(string [servername], string [username], string [password]);

返回值: 整数函数种类: 数据库功能 本函数用来打开与 Sybase 数据库的连接。

参数 servername 为欲连上的数据库服务器名称。

参数 username 及 password 可省略,分别为连接使用的帐号及密码。

使用本函数需注意早点关闭数据库,以减少系统的负担。

连接成功则返回数据库的连接代号,失败返回 false 值。

php获取指定网站的文章标题以及连接

写一个正则匹配就可以了

$html='li................../li';

preg_match_all('/lia href="(.*)"(.*)/aspan style="color:#F00;"(.*)/span/li/Ui',$html,$data);

print_R($data);//就有数据了注意空格那些都要和代码里的一致

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。