Migrate schools scraper from HTML scraping to xacen-backend REST API#5
Open
Migrate schools scraper from HTML scraping to xacen-backend REST API#5
Conversation
The education portal (ceice.gva.es) replaced the old ASP pages with a modern Angular SPA backed by a JSON REST API. The old HTML endpoints return 404. - Rewrite scraper to use xacen-backend API with JWT authentication - Fetch paginated school list and enrich with detail endpoints (datosGenerales, nivelesAutorizados, jornadas, informacionAdicional, servicios, programaLinguistico) - Transform API response to match legacy output schema (same 18 fields) - Always output both CSV and JSON in a single run - Use ThreadPoolExecutor instead of multiprocessing Pool - Remove local HTML mode (no longer applicable) - Drop beautifulsoup4, lxml, requests-cache, debugpy dependencies - Load .env via python-dotenv for non-Docker runs Made-with: Cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The education portal (ceice.gva.es) replaced its old ASP pages with a modern Angular SPA backed by a JSON REST API at
xacen-backend.gva.es. The old HTML scraping endpoints all return 404.This PR rewrites the schools scraper to use the new API:
GET /guiadecentros/listaCentrosAulariosLibre(100 per page, ~3700 schools across 39 pages)GETendpoints per school (datosGenerales,nivelesAutorizados,jornadas,informacionAdicional,servicios,programaLinguistico)schools.csvandschools.jsonin a single run (no moreOUTPUT_FORMATtoggle)codigo,denGenEs,deno,reg,dir,cp,muni,tel,email,com,titular,lat,long,cif,niveles,horario,info,inst)Changes
scraper.py: API client with JWT auth, pagination, retry with backoff, andThreadPoolExecutorfor concurrent detail fetchingmain.py: remove local HTML mode (--localflag)beautifulsoup4,lxml,requests-cache,debugpypython-dotenvloading for non-Docker runsREADME.mdto document the new API-based approachVerified against previous scrape
\rartifacts), no navigation icon titles ininst, no header labels inhorarioTest plan
uv run src/main.py --school-codes 03000047— single school detail fetchuv run src/main.py --subset 3— paginated list with subset--threads 15data.old/output