用PHP抓取网页内容

来源:互联网 发布:皓乐齿漱口水知乎 编辑:程序博客网 时间:2024/05/16 15:10
<html>
<head>
<title>实用抓取网页内容测试 </title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body  >
<?php
$url = 'http://localhost/test.php'//测试本地网页
#
$url = 'http://www.myenjoylife.cn/index.php'; //抓取www.myenjoylife.cn首页内容
$lines_array = file($url); 
$lines_string = implode('', $lines_array); 
eregi("(.*)", $lines_string, $head); 
echo $head[0]; 
?>
</body>
</html>
原创粉丝点击