Skip to content

Instantly share code, notes, and snippets.

@nelyj
Last active December 31, 2017 02:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nelyj/cf457b120f42e708caca426bcdae65cf to your computer and use it in GitHub Desktop.
Save nelyj/cf457b120f42e708caca426bcdae65cf to your computer and use it in GitHub Desktop.
SII scrapping to get folios
#mi github: https://github.com/nelyj
require 'uri'
require 'net/http'
url = "https://maullin.sii.cl/cvc_cgi/dte/of_solicita_folios"
headers = { "User-Agent" => "Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.63 Safari/534.3",
"Referer" => "https://hercules.sii.cl/cgi_AUT2000/autInicio.cgi?referencia=https://maullin.sii.cl/cvc_cgi/dte/of_solicita_folios",
"Content-Type" => "application/x-www-form-urlencoded" }
uri = URI.parse(url)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.cert = @certificate.certificate #OpenSSL::X509::Certificate
http.key = @certificate.key #OpenSSL::PKey::RSA
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
request = Net::HTTP::Get.new(uri.path)
request.initialize_http_header(headers)
#respuesta
#request.body => "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>302 Found</title>\n</head><body>\n<h1>Found</h1>\n<p>The document has moved <a href=\"https://hercules.sii.cl/cgi_AUT2000/autInicio.cgi?referencia=https://maullin.sii.cl/cvc_cgi/dte/of_solicita_folios\">here</a>.</p>\n</body></html>\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment