Work on updating the code for the new Cadastre web structure

parent 5283be6d
......@@ -404,7 +404,7 @@ class SpanishCadastreFetcher:
# First, open the form that directs us to the download
# this form includes the questions on what you're
# planning to use the data for
URL = 'https://www.sedecatastro.gob.es/CYCTitular/OVCFormularioDescargas.aspx'
URL = 'https://www.sedecatastro.gob.es/DescargaDatos/SECDescargaCartoSF.aspx'
data = {'hdTipologia': 'UA',
'hdDelegacion': municipality.mhap_delegation_id,
'hdMunicipio': municipality.mhap_id,
......@@ -581,7 +581,7 @@ class SpanishCadastreFetcher:
# We can now go to the download form and parse it
r = self.ovc_session.get(
'https://www.sedecatastro.gob.es/CYCTitular/OVCDescargaCartoSF.aspx')
'https://www.sedecatastro.gob.es/DescargaDatos/SECDescargaCartoSF.aspx')
if r.status_code != 200:
raise RuntimeError('Could not get authorization cookie')
doc = BeautifulSoup(r.text, 'html.parser')
......@@ -596,20 +596,16 @@ class SpanishCadastreFetcher:
if 'value' in node.attrs and 'type' in node.attrs and node.attrs['type'] == 'hidden':
data[node.attrs['name']] = node.attrs['value']
data['ctl00$body$cbMunicipio$hdDelegacion'] = provinceid
data['ctl00$body$cbMunicipio$hdProvincia'] = provinceid
data['ctl00$body$DropDownList1'] = provinceid
data['ctl00$body$cbMunicipio$hdMunicipio'] = municipalityname
data['ctl00$body$cbMunicipio$valorMunicipio'] = municipalityid
data['ctl00$body$cbMunicipio$tbMunicipio'] = municipalityname
data['ctl00$body$RadioButtonList1'] = 'UA' # Urbana sin historia
data['ctl00$body$Button1'] = 'Ver+capas+disponibles'
data['ctl00$body$chklstCapas$11'] = 'CONSTRU'
data['ctl00$Contenido$codigoProvincia'] = provinceid
data['ctl00$Contenido$codigoMunicipio'] = municipalityid
data['ctl00$Contenido$municipioSelector'] = municipalityname
data['ctl00$Contenido$RadioButtonList1'] = 'UA' # Urbana sin historia
data['ctl00$Contenido$Button1'] = 'Ver+capas+disponibles'
r = self.ovc_session.post(postURL, data=data)
if r.status_code != 200:
raise RuntimeError('Could not read cadastre data')
doc = BeautifulSoup(r.text, 'html.parser')
node = doc.find(id='ctl00_body_hdnFecha')
node = doc.find(id='ctl00_Contenido_hdnFecha')
if 'value' not in node.attrs:
return None
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment