Jay*_*ens 0 python web-crawler
我需要在本地抓取并存储以供将来分析有限的网站列表的内容.我基本上想要在所有页面中啜饮并按照所有内部链接来获取整个公开的网站.
是否有现有的免费图书馆让我在那里?我见过奇尔卡特,但这是为了报酬.我只是在这里寻找基线功能.思考?建议?
使用Scrapy.
它是一个基于扭曲的Web爬虫框架.仍处于重大发展阶段,但已经有效.有很多好吃的东西:
通过在返回的HTML上使用XPath选择器提取有关今天在mininova torrent网站中添加的所有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]
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3550 次 |
最近记录: |