Last active
December 31, 2017 02:08
-
-
Save nelyj/cf457b120f42e708caca426bcdae65cf to your computer and use it in GitHub Desktop.
SII scrapping to get folios
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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