這是我的正則表達式來獲取頁面上的圖像網址。從頁面源代碼解析圖像url
<?php
$url = $_POST['url'];
$data = file_get_contents($url);
$logo = get_logo($data);
function get_logo($html)
{
preg_match_all('/\bhttps?:\/\/\S+(?:png|jpg)\b/', $html, $matches);
//echo "mactch : $matches[0][0]";
return $matches[0][0];
}
?>
在正則表達式中是否缺少任何東西?對於一些網址,雖然他們有圖像,但它並沒有給出圖像網址。
例如:http://www.milanart.in/
它不給該網頁上的圖像。
請沒有圓頂。我無法使用它。 PHP的
可能重複的[你如何解析和處理PHP中的HTML/XML?](http://stackoverflow.com/questions/3577641/how-do-you-parse-and- process-html-xml-in-php) – Quentin