Se agrego fecha_de pago en la extraccion del xml
This commit is contained in:
@@ -219,6 +219,20 @@ class PedimentoScrapper: # Clase me extrae datos de Pedimento
|
||||
|
||||
return coves if coves else None
|
||||
|
||||
|
||||
def _get_fecha_pago(self, root: ET.Element) -> str:
|
||||
ns = {'ns2': 'http://www.ventanillaunica.gob.mx/pedimentos/ws/oxml/consultarpedimentocompleto'}
|
||||
for fechas in root.findall('.//ns2:fechas', ns):
|
||||
clave = fechas.find('./ns2:tipo/ns2:clave', ns)
|
||||
if clave is not None and clave.text == '2':
|
||||
fecha = fechas.find('./ns2:fecha', ns)
|
||||
if fecha is not None and fecha.text:
|
||||
# Extraer solo la parte de la fecha (YYYY-MM-DD)
|
||||
fecha_str = fecha.text
|
||||
# Si el formato es 'YYYY-MM-DD-06:00', tomar los primeros 10 caracteres
|
||||
return fecha_str[:10]
|
||||
return None
|
||||
|
||||
def extract_data(self, xml_content: str) -> dict:
|
||||
"""
|
||||
Método para extraer datos específicos del XML.
|
||||
@@ -244,6 +258,7 @@ class PedimentoScrapper: # Clase me extrae datos de Pedimento
|
||||
data['remesas'] = self._remesas(root)
|
||||
data['tipo_operacion'] = self._get_tipo_operacion(root)
|
||||
data['coves'] = self._get_cove(root)
|
||||
data['fecha_pago'] = self._get_fecha_pago(root)
|
||||
|
||||
# Verificar que se extrajeron los datos esenciales
|
||||
if not any([data['numero_operacion'], data['pedimento'], data['curp_apoderado'], data['agente_aduanal'], data['coves']]):
|
||||
|
||||
Reference in New Issue
Block a user