Guest User

Untitled

a guest
Feb 21st, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. Index: crawler.rb
  2. ===================================================================
  3. --- crawler.rb (revision 153)
  4. +++ crawler.rb (working copy)
  5. @@ -82,8 +82,9 @@
  6. @session.cookies.from_header(res['set-cookie']) if res.key?('set-cookie')
  7.  
  8. case res
  9. - when Net::HTTPRedirection : res = fetch(res['location'], {}, headers)
  10. - else
  11. + when Net::HTTPRedirection
  12. + @session.base_uris[-1] = @session.absolute_uri(res['location'])
  13. + res = fetch(res['location'], {}, headers)
  14. end
  15.  
  16. post.empty? and @cache.update(uri, res.body)
  17. Index: session.rb
  18. ===================================================================
  19. --- session.rb (revision 153)
  20. +++ session.rb (working copy)
  21. @@ -46,6 +46,9 @@
  22. attr_reader :crawler
  23.  
  24. ################################################################################
  25. + attr_reader :base_uris
  26. +
  27. + ################################################################################
  28. # Start a session using a HTTP GET
  29. def self.from_get (uri, &block)
  30. session = self.new
Add Comment
Please, Sign In to add comment