Last active
June 15, 2017 05:46
-
-
Save dmattosr/20d8db059e5a0bd3048b to your computer and use it in GitHub Desktop.
This file contains 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 | |
def get_data_doc_number(user, password, tipo_doc, numero_doc, format='json'): | |
''' | |
# url = 'http://py-devs.com:8888/api' | |
url = 'http://py-devs.com/api' | |
tipo_doc = 'dni' o 'ruc' | |
''' | |
url = 'http://py-devs.com/api' | |
# url = 'http://localhost:8000/api' | |
url = '%s/%s/%s' % (url, tipo_doc, str(numero_doc)) | |
res = {'error': True, 'message': None, 'data': {}} | |
try: | |
response = requests.get(url, auth=(user, password)) | |
except requests.exceptions.ConnectionError, e: | |
res['message'] = 'Error en la conexion' | |
return res | |
if response.status_code == 200: | |
res['error'] = False | |
res['data'] = response.json() | |
else: | |
try: | |
res['message'] = response.json()['detail'] | |
except Exception, e: | |
res['error'] = True | |
return res | |
res = get_data_doc_number('demorest', 'demo1234', 'dni', '09389109', format='json') | |
print 'error', res['error'] | |
print 'message', res['message'] | |
print 'data', res['data'] | |
res = get_data_doc_number('demorest', 'demo1234', 'ruc', '20100017491', format='json') | |
print 'error', res['error'] | |
print 'message', res['message'] | |
print 'data', res['data'] |
A saber, la reniec cobra por transacción a las entidades usuarias para consultas de dni, previa suscripción de un convenio.
Puedes indicar cual es la modalidad y/o medio de acceso al server de la reniec, o es una copia de la base de datos adquirida ilicitamente?
O alguna institución benéfica paga las consultas que se realizan a través de py-devs.com
Antes de usar esta api debo saber si es legal simplemente.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Claro rcronald, delito? no es nada de hacking. Todos los datos vienen de la pagina de sunat y reniec.