• 冒险村物语
  • 英雄无敌3塔防
  • 驾考家园手游

PHP截取远端网页资讯

2014-09-05

以下程序代码会介绍如何截取远端网页资讯,包括HTML tag 里面的Title, Description 及Keywords:
 
PLAIN TEXT
PHP:
<?php
//—–定义要截取的网页地址
$url = “http:// www.zhishiwu.com ”;
//—– 读取网页原始码
$fp = file_get_contents($url);
//—– 截取title 资讯
preg_match(“/<title>(.*)<//title>/s”, $fp, $match);
$title = $match[1];
//—– 截取Description 及Keywords
$metatag = get_meta_tags($url);
$description = $metatag["description"];
$keywords = $metatag["keywords"];
//—– 印出

人气推荐

知识阅读

精彩推荐

  • 游戏
  • 软件
查看更多>>