Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'uri'
- require 'net/http'
- URL = 'https://www.scraping-me.com/ok/dude';
- uri = URI.parse(URL)
- http = Net::HTTP.new(uri.host, uri.port)
- http.use_ssl = true
- http.set_debug_output($stdout)
- request = Net::HTTP::Post.new(uri.path)
- request['Content-Length'] = '0'
- p http.request(request)
- opening connection to www.scraping-me.com:443...
- opened
- starting SSL for www.scraping-me.com:443...
- SSL established
- <- "POST /ok/dude HTTP/1.1rnAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3rnAccept: */*rnUser-Agent: RubyrnContent-Length: 0rnConnection: closernHost: www.scraping-me.comrnContent-Type: application/x-www-form-urlencodedrnrn"
- <- ""
- -> "HTTP/1.1 403 Forbiddenrn"
- -> "Server: CloudFrontrn"
- -> "Date: Thu, 21 Jun 2018 13:23:20 GMTrn"
- -> "Content-Type: text/htmlrn"
- -> "Content-Length: 560rn"
- -> "Connection: closern"
- -> "X-Cache: Error from cloudfrontrn"
- -> "Via: 1.1 8c17e8fbe0b8e6fb8aa40ba7a7b911d2.cloudfront.net (CloudFront)rn"
- -> "X-Amz-Cf-Id: vQZZvIl543OJSbMxkmMWSrpsUFYaZJ6f2VOiAI_CQd8jTAteK8X73Q==rn"
- -> "rn"
- reading 560 bytes...
- -> "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">n<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">n<TITLE>ERROR: The request could not be satisfied</TITLE>n</HEAD><BODY>n<H1>403 ERROR</H1>n<H2>The request could not be satisfied.</H2>n<HR noshade size="1px">nRequest blocked.nn<BR clear="all">n<HR noshade size="1px">n<PRE>nGenerated by cloudfront (CloudFront)nRequest ID: vQZZvIl543OJSbMxkmMWSrpsUFYaZJ6f2VOiAI_CQd8jTAteK8X73Q==n</PRE>n<ADDRESS>n</ADDRESS>n</BODY></HTML>"
- read 560 bytes
- Conn close
- #<Net::HTTPForbidden 403 Forbidden readbody=true>
- request.instance_eval { @header.delete('user-agent') }
- request.instance_variable_get(:@header)
Add Comment
Please, Sign In to add comment