From ac50afa042c50ca9c50a9c9e8256ebbf018fc670 Mon Sep 17 00:00:00 2001 From: Jeffry Jesus De La Rosa Date: Fri, 11 Oct 2019 15:32:08 -0400 Subject: Change DGII form parameters DGII has changed their validation mechanism, so we first exract the __EVENTVALIDATION and __VIEWSTATE from the form and put them in the post request for validation. Closes https://github.com/arthurdejong/python-stdnum/pull/165 --- stdnum/do/ncf.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'stdnum/do/ncf.py') diff --git a/stdnum/do/ncf.py b/stdnum/do/ncf.py index aa4c924..2c1ae9b 100644 --- a/stdnum/do/ncf.py +++ b/stdnum/do/ncf.py @@ -173,10 +173,14 @@ def check_dgii(rnc, ncf, timeout=30): # pragma: no cover headers = { 'User-Agent': 'Mozilla/5.0 (python-stdnum)', } + result = BeautifulSoup( + requests.get(url, headers=headers, timeout=timeout).text) + validation = result.find('input', {'name': '__EVENTVALIDATION'})['value'] + viewstate = result.find('input', {'name': '__VIEWSTATE'})['value'] data = { - '__EVENTVALIDATION': '/wEWBAKh8pDuCgK+9LSUBQLfnOXIDAKErv7SBhjZB34//pbvvJzrbkFCGGPRElcd', - '__VIEWSTATE': '/wEPDwUJNTM1NDc0MDQ5ZGRCFUYoDcVRgzEntcKfSuvPnC2VhA==', - 'ctl00$cphMain$btnConsultar': 'Consultar', + '__EVENTVALIDATION': validation, + '__VIEWSTATE': viewstate, + 'ctl00$cphMain$btnConsultar': 'Buscar', 'ctl00$cphMain$txtNCF': ncf, 'ctl00$cphMain$txtRNC': rnc, } -- cgit v1.2.3