21,886
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>这里是标题</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://www.我自己的网址.com/myscript.js"></script>
<base href="http://www.抓取的网址.com/site1/" />
</head>
<body>
<img src="http://www.我自己的网址.com/images/abc.jpg" />
<!-- 抓取的内容 开始 -->
<img src="images/screenshots/3.jpg" />
<link rel="stylesheet" type="text/css" href="styles/sifrscreen.css" />
<script src="scripts/functions.js"></script>
<img src="/images/screenshots/3.jpg" />
<link rel="stylesheet" type="text/css" href="/styles/sifrscreen.css" />
<script src="/scripts/functions.js"></script>
<!-- 抓取的内容 结束 -->
</body>
</html>
$str = file_get_contents('http://www.mozillaonline.com/');
$str = preg_replace('/(?<=src=[\'"])(?!(\/|http))/sm', 'http://www.mozillaonline.com/', $str);
$str = preg_replace('/(?<=src=[\'"])(?=\\/)/sm', 'http://www.mozillaonline.com', $str);
$str = preg_replace('/(?<=href=[\'"])(?!(\/|http))/sm', 'http://www.mozillaonline.com/', $str);
$str = preg_replace('/(?<=href=[\'"])(?=\\/)/sm', 'http://www.mozillaonline.com', $str);
echo $str;
$str = '<img src="images/screenshots/3.jpg" />
<link href="styles/sifrscreen.css" />
<script src="scripts/functions.js" />
<img src="/images/aa.gif" />
';
$str = preg_replace('/(?<=src=[\'"])(?!(\/|http:))/sm', 'http://www.xxx.com/site1/', $str);
$str = preg_replace('/(?<=src=[\'"])(?=\\/)/sm', 'http://www.xxx.com', $str);
$str = preg_replace('/(?<=href=[\'"])(?!(\/|http:))/sm', 'http://www.xxx.com/site1/', $str);
$str = preg_replace('/(?<=href=[\'"])(?=\\/)/sm', 'http://www.xxx.com', $str);
echo $str;
$str = '
<img src="images/screenshots/3.jpg" />
<link href="styles/sifrscreen.css" />
<script src="scripts/functions.js" />
<img src="/images/aa.gif" />
';
$str = preg_replace('/(?<=src=[\'"])(?!(\/|http:))/sm', 'http://www.xxx.com/site1/', $str);
$str = preg_replace('/(?<=src=[\'"])(?=\\/)/sm', 'http://www.xxx.com/', $str);
$str = preg_replace('/(?<=href=[\'"])(?!(\/|http:))/sm', 'http://www.xxx.com/site1/', $str);
$str = preg_replace('/(?<=href=[\'"])(?=\\/)/sm', 'http://www.xxx.com/', $str);