Maison > Article > développement back-end > 小偷程序不能显示图片!!求助!!
PHP
<?phpheader("content-Type: text/html; charset=Utf-8");$url = "http://www.weather.com.cn/weather/101251401.shtml";$fp = @fopen($url, "r") or die("连接超时");$fcontent = file_get_contents($url);eregi("<div class=\"cleardiv\"></div>(.*)<script type=\"text/javascript\" src=\"http://m.weather.com.cn/a1.js\">",$fcontent,$we);$we[1] = str_replace("src=\"http://localhost/m2/i/icon_weather/29x20/", "src=\"http://www.weather.com.cn/m2/i/icon_weather/29x20/", $we[1]);echo $we[1];?>
取得的内容中,图片的连接是
src="/m2/i/icon_weather/29x20/"
src="http://localhost/m2/i/icon_weather/29x20/"
所以你的替换并没有成功
如果只是直接显示,那么可以配上来源在输出
echo str_replace('</head>', '<base href="http://www.weather.com.cn"></head>', $fcontent);
echo str_replace('<head>', '<head><base href="http://www.weather.com.cn">', $fcontent);
取得的内容中,图片的连接是
src="/m2/i/icon_weather/29x20/"
src="http://localhost/m2/i/icon_weather/29x20/"
所以你的替换并没有成功
如果只是直接显示,那么可以配上来源在输出
echo str_replace('</head>', '<base href="http://www.weather.com.cn"></head>', $fcontent);
echo str_replace('<head>', '<head><base href="http://www.weather.com.cn">', $fcontent);
header("content-Type: text/html; charset=Utf-8");
$url = "http://www.weather.com.cn/weather/101251401.shtml";
$fp = @fopen($url, "r") or die("连接超时");
$fcontent = file_get_contents($url);
echo str_replace('
header("content-Type: text/html; charset=Utf-8");
$url = "http://www.weather.com.cn/weather/101251401.shtml";
$fp = @fopen($url, "r") or die("连接超时");
$fcontent = file_get_contents($url);
echo str_replace('