| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
cgdf
10年前发布

PHP 获取指定URl页面中所有链接

    //获取指定URL页面中所有链接        function get_url_href($url){            $html = file_get_contents($url);            $dom = new DOMDocument();            @$dom->loadHTML($html);            $xpath = new DOMXPath($dom);            $hrefs = $xpath->evaluate('/html/body//a');            for($i=0;$i<$hrefs->length;$i++){                $href = $hrefs->item($i);                $url = $href->getAttribute('href');                if(substr($url,0,4) == 'http') echo $url.'<br>';            }        }