使用get_ _tags函数获取 信息
比如我们要获取http://www.taobao.com这个网页的 信息,可以直接使用php内置函数get_ _tags获取,代码如下:
<?php
$ _tags = get_ _tags(\"http://www.taobao.com\");
print_r($ _tags);
?>
结果输出:
Array
(
[renderer] => webkit
[spm-id] => a21bo
[de ion] => 淘宝网 - 亚洲最大、最安全的网上交易平台,提供各类服饰、美容、家居、数码、话费/点卡充值… 8亿优质特价商品,同时提供担保交易(先收货后付款)、先行赔付、假一赔三、七天无理由退换货、数码免费维修等安全交易保障服务,让你全面安心享受网上购物乐趣!
[keyword] =>
)
使用正则表达式获取 信息
PHP代码如下:
<##ads_in_article_manong##>
$site = \"http://www.manongjc.com\";
$content = get_site ($site);
print_r($content);
/** 获取 信息 */
function get_site ($url) {
$data = file_get_contents($url);
$ = array();
if (!empty($data)) {
#
preg_match(\'/< >([\\w\\W]*?)<\\/ >/si\', $data, $matches);
if (!empty($matches[1])) {
$ [\' \'] = $matches[1];
}
#Keywords
preg_match(\'/< \\s+name=\"keywords\"\\s+content=\"([\\w\\W]*?)\"/si\', $data, $matches);
if (empty($matches[1])) {
preg_match(\"/< \\s+name=\'keywords\'\\s+content=\'([\\w\\W]*?)\'/si\", $data, $matches);
}
if (empty($matches[1])) {
preg_match(\'/< \\s+content=\"([\\w\\W]*?)\"\\s+name=\"keywords\"/si\', $data, $matches);
}
if (empty($matches[1])) {
preg_match(\'/< \\s+http-equiv=\"keywords\"\\s+content=\"([\\w\\W]*?)\"/si\', $data, $matches);
}
if (!empty($matches[1])) {
$ [\'keywords\'] = $matches[1];
}
#De ion
preg_match(\'/< \\s+name=\"de ion\"\\s+content=\"([\\w\\W]*?)\"/si\', $data, $matches);
if (empty($matches[1])) {
preg_match(\"/< \\s+name=\'de ion\'\\s+content=\'([\\w\\W]*?)\'/si\", $data, $matches);
}
if (empty($matches[1])) {
preg_match(\'/< \\s+content=\"([\\w\\W]*?)\"\\s+name=\"de ion\"/si\', $data, $matches);
}
if (empty($matches[1])) {
preg_match(\'/< \\s+http-equiv=\"de ion\"\\s+content=\"([\\w\\W]*?)\"/si\', $data, $matches);
}
if (!empty($matches[1])) {
$ [\'de ion\'] = $matches[1];
}
}
return $ ;
} 继续阅读与本文标签相同的文章
上一篇 :
Flutter 之APP 生命周期
-
火币:火币土耳其将成为世界增长最快的加密社区之一
2026-05-14栏目: 教程
-
马化腾果断出手!微信将封禁砍价链接,网友:朋友圈终于清静了
2026-05-14栏目: 教程
-
5G技术引领世界,这次5G真的来了,科技让生活更美好
2026-05-14栏目: 教程
-
甲骨文联合CEO马克-赫德去世,曾因健康原因休假
2026-05-14栏目: 教程
-
华为5G如火如荼,爱立信却让美国失望:恐被罚款12亿美元!
2026-05-14栏目: 教程
