-
-
Save DiegoArrieta/2d32fc3bb8e3059ebf1c7f88080afdca to your computer and use it in GitHub Desktop.
Consulta de estado de documento de identidad registro civil Chile
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
import requests,urllib3, sys | |
from bs4 import BeautifulSoup | |
if len(sys.argv) < 3: | |
print('Usage: python registrocivil.py run docType docNumber') | |
sys.exit('ex: python registrocivil.py 11111111-K CEDULA 10600000') | |
URL="https://portal.sidiv.registrocivil.cl/usuarios-portal/pages/DocumentRequestStatus.xhtml" | |
headers={"Content-Type":"application/x-www-form-urlencoded", | |
"User-Agent":"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36"} | |
Run=sys.argv[1] | |
docType=sys.argv[2] #{CEDULA,CEDULA_EXT,PASAPORTE_PG,PASAPORTE_DIPLOMATICO,PASAPORTE_OFICIAL} | |
docNumber=sys.argv[3] #https://www.srcei.cl/PortalSIDIV/ayuda_documento.html | |
urllib3.disable_warnings() | |
s=requests.Session() | |
s.headers.update(headers) | |
r=s.get(URL, verify=False) | |
soup=BeautifulSoup(r.content,"html.parser") | |
viewState=soup.find(id="javax.faces.ViewState")['value'] | |
data={"form":"form", "form:run":Run, "form:selectDocType":docType, | |
"form:docNumber":docNumber,"form:buttonHidden":"","javax.faces.ViewState":viewState} | |
r=s.post(URL, data=data) | |
soup=BeautifulSoup(r.content,"html.parser") | |
data = [] | |
table = soup.find('table', attrs={'class':'tableResult'}) | |
table_body = table.find('tbody') | |
print table_body |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment