正在分析页面源代码中的图像url


Parsing image url from source code of the page

这是我的正则表达式,用于获取页面上的图像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];  
            }
?>

正则表达式中缺少什么吗?对于一些url,它没有给出图像url,尽管它们中有图像。

例如:http://www.milanart.in/

它不会在该页面上显示图像。

请不要圆顶。我无法使用它。

<?php       
    $url = "http://www.milanart.in";       
    $data = file_get_contents($url);  
    $logo = get_logo($data);
    function get_logo($html) 
        {
            preg_match_all("/<img src='"(.*?)'"/", $html, $matches);
            return $matches[1][0];  
        }
    echo 'logo path : '.$logo;
    echo '<img src="'.$url.'/'.$logo.'" />';
?>

使用PHP的DOM类获取所有图像:

  1. 在CSS中搜索图像文件。。。。。url(imagefilename.extension)
  2. 在HTML中搜索图像文件