小偷程式不能顯示圖片!!求助!!

來源:互聯網
上載者:User
PHP

",$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];?>

我是看PHP100視頻照著寫的,但是圖片就是顯示不出來...
以下是:

下面是天氣預報網站的圖片的地址


回複討論(解決方案)

取得的內容中,圖片的串連是
src="/m2/i/icon_weather/29x20/"
src="http://localhost/m2/i/icon_weather/29x20/"
所以你的替換並沒有成功

如果只是直接顯示,那麼可以配上來源在輸出

echo str_replace('', '', $fcontent);


你可以明顯的看到樣式沒有了
改成這樣才會有樣式
echo str_replace('', '', $fcontent);

通常的做法是將樣式表、圖片抓回到本地。當然也存在一定的技術難度

取得的內容中,圖片的串連是
src="/m2/i/icon_weather/29x20/"
src="http://localhost/m2/i/icon_weather/29x20/"
所以你的替換並沒有成功

如果只是直接顯示,那麼可以配上來源在輸出

echo str_replace('', '', $fcontent);


你可以明顯的看到樣式沒有了
改成這樣才會有樣式
echo str_replace('', '', $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('', '', $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('', '', $fcontent);//就加這句,其他都是你的

額 ,這樣顯示出來太多了吧.....我只想弄個天氣

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.