Advertisement
Guest User

pic_dl.rb

a guest
Sep 2nd, 2014
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. require 'net/http'
  2. require 'net/https'
  3.  
  4. path = "https://2ch.hk/pr/res/380039.html"
  5.  
  6. uri = URI(path)
  7.  
  8. http = Net::HTTP.new(uri.host, uri.port)
  9. http.use_ssl = true
  10.  
  11. def get_cookie(header)
  12.   header.slice(0, header.index(";"))
  13. end
  14.  
  15. res = http.get(uri.path)
  16. cfduid = get_cookie res["set-cookie"]
  17.  
  18. wtf_is_this_url = "https://2ch.hk/cdn-cgi/l/chk_jschl?jschl_vc=cb51d68ec5e478745fa6617e6c5ac683&jschl_answer=314"
  19. res = http.get(wtf_is_this_url, { "cookie" => cfduid })
  20.  
  21. cf_clearance = get_cookie res["set-cookie"]
  22.  
  23. res = http.get(path, { "cookie" => "#{cfduid}; #{cf_clearance}" })
  24.  
  25. p res # <Net::HTTPOK 200 OK readbody=true>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement