2017-10-15 64 views
0

有這個圖像生成 - 它看起來像html,我想下載圖像編程,我第一次嘗試wget但得到錯誤500,使用瀏覽器下載圖像和鼠標右鍵單擊工作正常。 有沒有辦法做到這一點編程?以編程方式下載用html/php生成的圖像

<img style="-webkit-user-select: none;background-position: 0px 0px, 10px 10px;background-size: 20px 20px;background-image:linear-gradient(90deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee 100%),linear-gradient(45deg, #eee 50%, white 25%, white 75%, #eee 75%, #eee 100%);" src="https://example.com/image.php"> 

回答

0

PHP函數可用於在服務器上保存的文件:

<?php echo file_put_contents("image_script.php","output_to_file.jpg"); ?> 
+0

但我怎麼能做到這一點programaticaly,因爲我不能wget的例如下載網頁的源代碼。 –

+0

現在我正在考慮使用硒並模擬鼠標右鍵單擊 –

+0

您是否有權訪問服務器的後端?您是否介意在圖像中發佈URL? – Zelenko