lectura boe
This commit is contained in:
parent
0c3acffeb9
commit
58bc4ef47e
|
|
@ -3,9 +3,107 @@ import xml.etree.ElementTree as ET
|
|||
import datetime
|
||||
|
||||
today = datetime.date.today()
|
||||
url = f"https://www.boe.es/datosabiertos/api/boe/sumario/{today.strftime('%Y%m%d')}"
|
||||
|
||||
response = requests.get(url)
|
||||
# url = f"https://www.boe.es/datosabiertos/api/boe/sumario/{today.strftime('%Y%m%d')}"
|
||||
urlraiz = "https://www.boe.es/datosabiertos/api/boe/sumario/"
|
||||
|
||||
def buscarenboe(fecha):
|
||||
url = f"{urlraiz}{fecha}"
|
||||
|
||||
headers = {
|
||||
"Accept": "application/xml"
|
||||
}
|
||||
|
||||
response = requests.get(url, headers=headers)
|
||||
|
||||
root = ET.fromstring(response.content)
|
||||
|
||||
INCLUDE_EPIGRAFES = [
|
||||
"Oposiciones y concursos",
|
||||
"Personal funcionario",
|
||||
"Procesos selectivos"
|
||||
]
|
||||
|
||||
EXCLUDE_EPIGRAFES = [
|
||||
"Anuncios",
|
||||
"Contratación",
|
||||
"Licitaciones"
|
||||
]
|
||||
|
||||
EXCLUDE_TITULOS = [
|
||||
"libre designación",
|
||||
"proveer puesto de trabajo",
|
||||
"sistema de concurso",
|
||||
"concurso específico",
|
||||
"concurso de méritos",
|
||||
]
|
||||
|
||||
INCLUDE_TITULOS = [
|
||||
"proceso selectivo",
|
||||
"pruebas selectivas",
|
||||
"oposición",
|
||||
"concurso-oposición",
|
||||
"bolsa de trabajo",
|
||||
"interinos",
|
||||
"estabilización",
|
||||
"ingreso libre",
|
||||
"cuerpo general",
|
||||
"tecnologías de la información",
|
||||
]
|
||||
|
||||
for seccion in root.iter("seccion"):
|
||||
|
||||
nombre_seccion = seccion.attrib.get("nombre", "")
|
||||
|
||||
for departamento in seccion.iter("departamento"):
|
||||
|
||||
nombre_departamento = departamento.attrib.get("nombre", "")
|
||||
|
||||
for epigrafe in departamento.iter("epigrafe"):
|
||||
|
||||
nombre_epigrafe = epigrafe.attrib.get("nombre", "")
|
||||
|
||||
# excluir epígrafes basura
|
||||
if nombre_epigrafe in EXCLUDE_EPIGRAFES:
|
||||
continue
|
||||
|
||||
# incluir interesantes
|
||||
relevante = (
|
||||
nombre_epigrafe in INCLUDE_EPIGRAFES
|
||||
)
|
||||
|
||||
for item in epigrafe.iter("item"):
|
||||
|
||||
titulo = item.find("titulo")
|
||||
|
||||
if titulo is None:
|
||||
continue
|
||||
|
||||
texto = titulo.text or ""
|
||||
texto_lower = texto.lower()
|
||||
|
||||
# excluir ruido
|
||||
if any(x in texto_lower for x in EXCLUDE_TITULOS):
|
||||
continue
|
||||
|
||||
# incluir solo cosas interesantes
|
||||
if not any(x in texto_lower for x in INCLUDE_TITULOS):
|
||||
continue
|
||||
|
||||
if relevante:
|
||||
|
||||
print()
|
||||
print("=" * 80)
|
||||
print("SECCIÓN:", nombre_seccion)
|
||||
print("DEPARTAMENTO:", nombre_departamento)
|
||||
print("EPÍGRAFE:", nombre_epigrafe)
|
||||
print("TÍTULO:", texto)
|
||||
|
||||
|
||||
for dia in range(1, 31):
|
||||
|
||||
fecha = f"202512{dia:02d}"
|
||||
print(f"Consultando {fecha}...")
|
||||
buscarenboe(fecha)
|
||||
|
||||
|
||||
print(response.status_code)
|
||||
print(response.text[:1000]) # primeros caracteres
|
||||
Loading…
Reference in New Issue