Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

226
Vistas
Axios blocked by CORS but HTMLParser isn't? (Web Browser Scraper)

I have a Python web scraper using the HTMLParser module. The website it scraps is http://consulta.siiau.udg.mx/wco/sspseca.consulta_oferta?ciclop=202120&cup=D&mostrarp=100000&ordenp=2

Now I need to do the same but web browser based using javascript, so I tried fetching the raw HTML using axios but I keep getting 'Access to XMLHttpRequest has been blocked by CORS policy'.

What I have tried is

axios.post('http://consulta.siiau.udg.mx/wco/sspseca.consulta_oferta', {
        ciclop: '202120',
        cup: 'D',
        mostrarp: 10000,
        ordennp: 2,
      })
      .then((response) => {
        console.log(response)
      })

And

axios.get('http://consulta.siiau.udg.mx/wco/sspseca.consulta_oferta?ciclop=202120&cup=D&mostrarp=100000&ordenp=2',
        { crossdomain: true }
      )
      .then((response) => {
        console.log(response)
      })

I am aware that in javascript they normally use a headless browser like the one inside Puppeteer, but since this project is a website I can't use Node.js modules.

Right now the solution I implemented is to have a server running a Flask API that handles the html fetching and then sends it back to the client for processing, but it would be a relieve for my server performance if the client could do this on his side.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

In short, you can't use the fetch API or XMLHTTPRequest to access resources that aren't allowed by the browser's cross-origin policy.

For security reasons, browsers restrict HTTP requests initiated from scripts. A web application can only request resources from the same origin the application was loaded from unless the response from other origins includes the right CORS headers.

You can use a headless browser (puppeteer) to access a web page, for example using:

 await page.goto('https://example.com');

This is equivalent to putting http://example.com in the browser bar and pressing ENTER. Any scripts on that page are subject to the same cross-origin restrictions as before. However, telling the browser to visit http://example.com isn't a cross-origin request in itself.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda