Image 无铬-从网页获取所有图像src

Image 无铬-从网页获取所有图像src,image,html-parsing,chromeless,Image,Html Parsing,Chromeless,我正在尝试使用Chromeless获取HTML页面中所有img标记的src值。我当前的实现是这样的: async function run() { const chromeless = new Chromeless(); let url = 'http://someurl/somepath.html'; var allImgUrls = await chromeless .goto(url) .evaluate(() => docu

我正在尝试使用Chromeless获取HTML页面中所有img标记的src值。我当前的实现是这样的:

async function run() {
    const chromeless = new Chromeless();
    let url = 'http://someurl/somepath.html';

    var allImgUrls = await chromeless
        .goto(url)
        .evaluate(() => document.getElementsByTagName('img'));

    var htmlContent = await chromeless
        .goto(url)
        .evaluate(() => document.documentElement.outerHTML );

    console.log(allImgUrls);

    await chromeless.end()
}

问题是,
allImgUrls
中没有img对象的任何值

经过一些研究,我们发现我们可以使用这种方法:

var imgSrcs = await chromeless
        .goto(url)
        .evaluate(() => {
            /// since document.querySelectorAll doesn't actually return an array but a Nodelist (similar to array)
            /// we call the map function from Array.prototype which is equivalent to [].map.call()
            const srcs = [].map.call(document.querySelectorAll('img'), img => img.src);
            return JSON.stringify(srcs);
        });