python-stdnum branch master updated. 1.13-3-gefa70f1
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
python-stdnum branch master updated. 1.13-3-gefa70f1
- From: Commits of the python-stdnum project <python-stdnum-commits [at] lists.arthurdejong.org>
- To: python-stdnum-commits [at] lists.arthurdejong.org
- Reply-to: python-stdnum-users [at] lists.arthurdejong.org, python-stdnum-commits [at] lists.arthurdejong.org
- Subject: python-stdnum branch master updated. 1.13-3-gefa70f1
- Date: Tue, 18 Feb 2020 21:09:06 +0100 (CET)
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "python-stdnum".
The branch, master has been updated
via efa70f1ece9f30bf7e6a8600534bbb37e751c53e (commit)
from e513888762af9c0d5fd698810e124cb9b5a47a92 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://arthurdejong.org/git/python-stdnum/commit/?id=efa70f1ece9f30bf7e6a8600534bbb37e751c53e
commit efa70f1ece9f30bf7e6a8600534bbb37e751c53e
Author: Gustavo Valverde <gustavo@iterativo.do>
Date: Tue Feb 18 14:18:39 2020 -0400
Change DGII endpoint to new one
The old endpoint has been deprecated.
Closes https://github.com/arthurdejong/python-stdnum/pull/190
diff --git a/stdnum/do/ncf.py b/stdnum/do/ncf.py
index b9bb3d9..d4994de 100644
--- a/stdnum/do/ncf.py
+++ b/stdnum/do/ncf.py
@@ -133,10 +133,13 @@ def _convert_result(result): # pragma: no cover
'MENSAJE_VALIDACION': 'validation_message',
'RNC': 'rnc',
'NCF': 'ncf',
+ u'RNC / Cédula': 'rnc',
u'RNC/Cédula': 'rnc',
+ u'Nombre / Razón Social': 'name',
u'Nombre/Razón Social': 'name',
'Estado': 'status',
'Tipo de comprobante': 'type',
+ u'Válido hasta': 'valid_until',
}
return dict(
(translation.get(key, key), value)
@@ -168,13 +171,14 @@ def check_dgii(rnc, ncf, timeout=30): # pragma: no cover
from stdnum.do.rnc import compact as rnc_compact
rnc = rnc_compact(rnc)
ncf = compact(ncf)
- url = 'https://www.dgii.gov.do/app/WebApps/ConsultasWeb/consultas/ncf.aspx'
- headers = {
+ url =
'https://dgii.gov.do/app/WebApps/ConsultasWeb2/ConsultasWeb/consultas/ncf.aspx'
+ session = requests.Session()
+ session.headers.update({
'User-Agent': 'Mozilla/5.0 (python-stdnum)',
- }
+ })
# Get the page to pick up needed form parameters
document = lxml.html.fromstring(
- requests.get(url, headers=headers, timeout=timeout).text)
+ session.get(url, timeout=timeout).text)
validation =
document.find('.//input[@name="__EVENTVALIDATION"]').get('value')
viewstate = document.find('.//input[@name="__VIEWSTATE"]').get('value')
data = {
@@ -186,13 +190,13 @@ def check_dgii(rnc, ncf, timeout=30): # pragma: no cover
}
# Do the actual request
document = lxml.html.fromstring(
- requests.post(url, headers=headers, data=data, timeout=timeout).text)
- result = document.find('.//div[@id="ctl00_cphMain_pResultado"]')
+ session.post(url, data=data, timeout=timeout).text)
+ result = document.find('.//div[@id="cphMain_pResultado"]')
if result is not None:
data = {
- 'validation_message':
document.findtext('.//*[@id="ctl00_cphMain_lblInformacion"]').strip(),
+ 'validation_message':
document.findtext('.//*[@id="cphMain_lblInformacion"]').strip(),
}
data.update(zip(
- [x.text.strip().rstrip(':') for x in result.findall('.//strong')],
- [x.text.strip() for x in result.findall('.//span')]))
+ [x.text.strip() for x in result.findall('.//th')],
+ [x.text.strip() for x in result.findall('.//td/span')]))
return _convert_result(data)
-----------------------------------------------------------------------
Summary of changes:
stdnum/do/ncf.py | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
hooks/post-receive
--
python-stdnum
- python-stdnum branch master updated. 1.13-3-gefa70f1,
Commits of the python-stdnum project