Home > Blockchain >  Error on Goto function on playwright when navigate to PDF file
Error on Goto function on playwright when navigate to PDF file

Time:10-19

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.

CodePudding user response:

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();

CodePudding user response:

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);
  • Related