2024-06-01 08:07:01 发布
网友
我有点想自己写,但我现在真的没有足够的时间。我看过维基百科上的open source crawlers列表,但我更喜欢用Python编写的东西。我意识到我可能只需要使用维基百科页面上的一个工具并用Python包装它。我可能会这样做-如果有人对这些工具有任何建议,我愿意听取他们的意见。我通过Heritrix的web界面使用过它,我发现它非常麻烦。我绝对不会在我即将进行的项目中使用浏览器API。
提前谢谢。还有,这是我的第一个问题!
使用Scrapy。
它是一个基于twisted的网络爬虫框架。仍在大力发展中,但已经奏效。有很多优点:
通过在返回的HTML上使用XPath选择器来提取有关今天在mininovatorrent站点中添加的所有torrent文件的信息的示例代码:
class Torrent(ScrapedItem): pass class MininovaSpider(CrawlSpider): domain_name = 'mininova.org' start_urls = ['http://www.mininova.org/today'] rules = [Rule(RegexLinkExtractor(allow=['/tor/\d+']), 'parse_torrent')] def parse_torrent(self, response): x = HtmlXPathSelector(response) torrent = Torrent() torrent.url = response.url torrent.name = x.x("//h1/text()").extract() torrent.description = x.x("//div[@id='description']").extract() torrent.size = x.x("//div[@id='info-left']/p[2]/text()[2]").extract() return [torrent]
检查用Python编写的多线程web爬虫HarvestMan,同时查看spider.py模块。
并且here您可以找到代码示例来构建一个简单的web爬虫程序。
使用Scrapy。
它是一个基于twisted的网络爬虫框架。仍在大力发展中,但已经奏效。有很多优点:
通过在返回的HTML上使用XPath选择器来提取有关今天在mininovatorrent站点中添加的所有torrent文件的信息的示例代码:
检查用Python编写的多线程web爬虫HarvestMan,同时查看spider.py模块。
并且here您可以找到代码示例来构建一个简单的web爬虫程序。
相关问题 更多 >
编程相关推荐