-1

I am using this code in C# and it is working properly.

using PuppeteerSharp;

var links = page.EvaluateExpressionAsync<string[]>
            ("Array.from(document.querySelectorAll('a span'))
            .map(a => a.textContent);").Result;

But when i tried to convert JavaScript using this code, it is not working.

const puppeteerChrome = require('puppeteer');

const links = await page.evaluate(() => 
                    Array.from(document.querySelectorAll('a span'))
                   .map(a => a.textContent));

How can i solve this problem.

Can Ali
  • 341
  • 3
  • 10

1 Answers1

0

I solved the problem like this.

const links = await page.evaluate(() =>
              Array.from(document.querySelectorAll('a span'), e => 
              e.textContent));
Can Ali
  • 341
  • 3
  • 10