只是想知道是否有人可以通过以下方式进一步帮助我.我想解析这个网站上的URL:http://www.directorycritic.com/free-directory-list.html?pg = 1&sort = pr
我有以下代码:
<?PHP
$url = "http://www.directorycritic.com/free-directory-list.html?pg=1&sort=pr";
$input = @file_get_contents($url) or die("Could not access file: $url");
$regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>";
if(preg_match_all("/$regexp/siU", $input, $matches)) {
// $matches[2] = array of link addresses
// $matches[3] = array of link text - including HTML code
}
?>
Run Code Online (Sandbox Code Playgroud)
目前没有做什么,我需要做的是废弃所有16页的表中的所有URL,并且非常感谢一些帮助,如何修改上述内容并将URL输出到文本文件中.