fetch site in ruby


/ Published in: Ruby
Save to your folder(s)



Copy this code and paste it in your HTML
  1. #!/usr/local/bin/ruby
  2. require 'rubygems'
  3. require 'curl-multi'
  4.  
  5.  
  6. curl = Curl::Multi.new
  7.  
  8.  
  9. on_success = lambda do |body|
  10. puts body
  11. end
  12.  
  13. on_failure = lambda do |ex|
  14. puts 'Failure.'
  15. puts ex
  16. end
  17.  
  18.  
  19. curl.get('http://www.wp.pl', on_success, on_failure)
  20. curl.select([],[]) while curl.size > 0;

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.