我获取到页面内容首先判断页面href里如果有http的则忽略,没有http的则加上域名
比如<href='style.css'>变成<href='http://abc.com/style.css'>

解决方案 »

  1.   

    以前尝试过,未遂。总拼不好。
    这个文件不光是域名的问题,他是一个相对路径。像/style.css可以添个域名,../style.css就要在当前目录往上一次……
      

  2.   


    "/<href='(http:\/\/)?(.+?)\/(.+)'>/i"
      

  3.   

    这个可以匹配出'http://abc.com/style.css
      

  4.   

    <?
    $varstr="<href='http://abc.com/style.css'>dgdgdgg";
    $rex1="/<href=\'(http:\/\/)?([^\/]+)(\/)?([^']+)\'>/i";
    preg_match_all($rex1,$varstr,$data1);
    print_r($data1);
    ?>