【发布时间】:2011-08-09 17:18:57
【问题描述】:
我一直想知道如何做这样的事情。我不是该网站的所有者/管理员/网站管理员 (http://poolga.com/),但我希望获得的信息是公开的。此页面 (http://poolga.com/artists) 是所有为网站做出贡献的艺术家的目录。但是,此页面上的链接会转到包含此锚标记的另一个页面,该标记包含指向艺术家实际网站的链接。
<a id="author-url" class="helv" target="_blank" href="http://aaaghr.com/">http://aaaghr.com/</a>
我讨厌必须命令 + 单击目录中的链接,然后单击指向艺术家网站的链接。我希望有一种方法可以让一批 10 个艺术家网站链接在浏览器中显示为选项卡,仅供临时查看。然而,仅仅将这些 href 放入某种数组本身就是一项壮举。任何编程语言中的任何想法或方向/谷歌搜索都很棒!这甚至会被称为“爬行”吗?感谢阅读!
更新
我用这个脚本在我的本地 php MAMP 服务器上使用了 Simple HTML DOM,花了一点时间!
$artistPages = array();
foreach(file_get_html('http://poolga.com/artists')->find('div#artists ol li a') as $element){
array_push($artistPages,$element->href);
}
for ($counter = 0; $counter <= sizeof($artistPages)-1; $counter += 1) {
foreach(file_get_html($artistPages[$counter])->find('a#author-url') as $element){
echo $element->href . '<br>';
}
}
【问题讨论】:
-
很多主题都涉及到同样的事情:stackoverflow.com/search?q=%2Bhow+web+crawler 也可以查看 simple_html_dom。
标签: php javascript ajax