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

244
Vistas
Error on Goto function on playwright when navigate to PDF file

I have this link https://nfse.blumenau.sc.gov.br/contrib/app/nfse/rel/rp_nfse_v23.aspx?s=61154301&e=00165960000101&f=2BED3D1E8 (if you try to access its gonna ask to solve a captcha but as long as i already have the session, the playwright doesnt need to worry it).

OUT page.goto: net::ERR_ABORTED at https://nfse.blumenau.sc.gov.br/contrib/app/nfse/rel/rp_nfse_v23.aspx?s=61154301&e=00165960000101&f=2BED3D1E8

Anybody knows why playwright cannot access it? I need to download the PDF Buffer of this link.

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

0

Found a Solution:

First i didnt concatenate the cookie on the calling of the function

const cook = 'ASP.NET_SessionId=' + cookie;    
await setCookie(cook, urlFinal);

Then i used the got module to put the cookie and get the buffer of the pdf:

response = await got(urlFinal, {cookieJar}).buffer();

Plus: Sometimes it returned a blank pdf (i think because of the timeout of loading it). So i inserted a loop to check the size of the buffer and tried 20 times until it gets more than 'X' of lenght.

for (let j = 0;j<=25;j++){
                                console.log('Entrei no looping ==> ' + j);
                                response = await got(urlFinal, {cookieJar}).buffer();
                                if (response.toString().length>=10000){
                                    j=21;
                                }
                            }
                            console.log('tamanho do buffer ==> ' + response.toString().length);
about 4 years ago · Juan Pablo Isaza Denunciar

0

You can use the fetch API. Something like this:

const fetchResponse = browserContect.request.get('https://nfse.blumenau.sc.gov.br/contrib/app/nfse/rel/rp_nfse_v23.aspx?s=61154301&e=00165960000101&f=2BED3D1E8')
const pdfBuffer = await fetchResponse.body();
about 4 years ago · Juan Pablo Isaza Denunciar

0

I tried that already but didnt work either:

const cookie = (await page.context().cookies()).filter(cookie => cookie.name === 'ASP.NET_SessionId')
                                               .map(cookie => cookie.value)[0];
console.log(cookie);
const cookieJar = new CookieJar();
const setCookie = promisify(cookieJar.setCookie.bind(cookieJar));

await setCookie('ASP.NET_SessionId=' + cookie, urlFinal);

const response = await got(urlFinal, {cookieJar}).buffer();

its really a challenge. Because if i wont go with page.goto i loose the session. The code bellow would solve the problem.

await page.goto(urlFinal);
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