Spidr 是一个Ruby 的网页爬虫库,可以将整个网站、多个网站、某个链接完全抓取到本地。
安装方法:sudo gem install spidr
Spidr.start_at('http://tenderlovemaking.com/')
Spidr.host('coderrr.wordpress.com')
Spidr.site('http://rubyflow.com/')
Spidr.start_at( 'http://company.com/', :hosts => [ 'company.com', /host\d\.company\.com/ ] )
Spidr.site('http://matasano.com/', :ignore_links => [/log/])
Spidr.site( 'http://sketchy.content.com/', :ignore_ports => [8000, 8010, 8080] )
Spidr.site('http://rubyinside.org/') do |spider| spider.every_url { |url| puts url } end
Spidr.site('http://sketchy.content.com/') do |spider| spider.every_failed_url { |url| puts url } end
Spidr.site('http://company.withablog.com/') do |spider| spider.every_page do |page| puts "[-] #{page.url}" page.search('//meta').each do |meta| name = (meta.attributes['name'] || meta.attributes['http-equiv']) value = meta.attributes['content'] puts " #{name} = #{value}" end end end
Spidr.site('http://www.rubypulse.com/') do |spider| spider.every_html_page do |page| puts page.title end end
servers = Set[] Spidr.host('generic.company.com') do |spider| spider.all_headers do |headers| servers << headers['server'] end end
spider = Spidr.host('overnight.startup.com') do |spider| spider.every_forbidden_page do |page| spider.pause! end end
Spidr.host('sketchy.content.com') do |spider| spider.every_missing_page do |page| spider.skip_page! end end
Spidr.host('sketchy.content.com') do |spider| spider.every_url do |url| if url.path.split('/').find { |dir| dir.to_i > 1000 } spider.skip_link! end end end