我正在使用file_get_contents抓取一个页面,但我需要在回显页面内容之前替换一些数据。使用str_replace和file_get_contents
我有这个迄今为止(这个脚本在运行domain2.com)
<?php
$page = file_get_contents('http://domain.com/page.html');
str_replace('href="/','href="http://domain.com','$page');
echo $page;
?>
的问题是,当页面显示,该domain.com页面上的一些链接阅读:
<a href=/about.html>
当我在我的脚本中调用时,正在将它添加到不正确的域。我试着用str_replace函数,寻找
href="/
与
href="http://www.domain.com/
但它不工作更换。任何线索?
我删除了我的答案,因为如果执行会有一吨与它的问题。 – 2009-08-01 05:58:29