[英]How can i convert puppeteer Array.from().map() from C# to JavaScript
I am using this code in C# and it is working properly.我在 C# 中使用此代码,它工作正常。
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.但是当我尝试使用此代码转换 JavaScript 时,它不起作用。
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.我怎么解决这个问题。
I solved the problem like this.我解决了这样的问题。
const links = await page.evaluate(() =>
Array.from(document.querySelectorAll('a span'), e =>
e.textContent));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.