Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/ruby
- =begin rdoc
- exemplo de uso da gem anemone
- autor: Cooler_
- COntato: [email protected]
- exemplo:
- Para extrair todas URLs de forma recursiva de um host
- ========================================================
- gem install anemone
- =end
- require 'rubygems'
- require 'anemone'
- if(ARGV[0])
- puts ARGV[0]
- # soh exemplo pegando todas URLs de um host qualquer
- Anemone.crawl(ARGV[0],opts ={
- :threads => 8,
- :user_agent => "Hellblazer browser , utf8 , NetBSD 4.1 ",
- :delay => 0,
- :depth_limit => false,
- :accept_cookies => false,
- }) do |anemone|
- anemone.on_every_page do |page|
- forms= page.doc.at('form').inner_html rescue nil
- puts "--------------------------------"
- # onde tem GET
- if page.url =~ /=/
- puts "GET HERE: #{page.url}"
- end
- # onde tem formulario
- if forms
- puts "FORM HERE: #{page.url} "
- end
- end
- end
- else
- puts "recursive url extractor\nfollow example\nruby code.rb http://site.com"
- end
Advertisement
Add Comment
Please, Sign In to add comment