【发布时间】:2011-05-26 13:20:43
【问题描述】:
只是想知道是否有人可以在以下方面进一步帮助我。我要解析这个网站的网址: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
}
?>
目前什么都不做,我需要做的是废弃表中所有 16 个页面的所有 URL,并且非常感谢有关如何修改上述内容以执行此操作并将 URL 输出到文本文件中的一些帮助。
【问题讨论】:
标签: php html parsing html-parsing