diff options
author | Jeffry Jesus De La Rosa <jeffryjesus@gmail.com> | 2019-10-11 21:32:08 +0200 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2019-10-13 15:30:47 +0200 |
commit | ac50afa042c50ca9c50a9c9e8256ebbf018fc670 (patch) | |
tree | 26687c8813b7f80eee25c9a367657c733a9a75ca /stdnum/do/ncf.py | |
parent | aadf121db70868370bfcfc7f9f9674e7adf0fb69 (diff) |
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
Diffstat (limited to 'stdnum/do/ncf.py')
-rw-r--r-- | stdnum/do/ncf.py | 10 |
1 files changed, 7 insertions, 3 deletions
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, } |