TypeError [ERR_INVALID_ARG_TYPE]:“原始"参数必须是类型为puppeteer node js的函数 [英] TypeError [ERR_INVALID_ARG_TYPE]: The "original" argument must be of type function puppeteer node js

查看:3638
本文介绍了TypeError [ERR_INVALID_ARG_TYPE]:“原始"参数必须是类型为puppeteer node js的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里呆了一段时间,我不明白问题所在.有人在这个问题上启发了我.这是代码.

I am stuck here for a while I didn't understand the problem. Kindly someone enlightens me on this topic. here's the code.

const puppeteer = require('puppeteer');
(async() => {
    let infourl = 'https://www.imdb.com/title/tt0111161/?ref_=fn_al_tt_3';
    let browser = await puppeteer.launch();
    let page = await browser.newPage();
    await page.goto(infourl, { waitUntil:'networkidle2' });
    let data = await page.evaluate( () =>{
        let stats = document.querySelector('div[class="title_wrapper"]').innerText;
        return {stats};
    });
    console.log(data);
    debugger;
    await browser.close();
})();

这是日志::

internal/util.js:209
    throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'original', 'function');
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "original" argument must be of type function
    at promisify (internal/util.js:209:11)
    at Object.<anonymous> (/home/hadi/Desktop/datachori/node_modules/extract-zip/index.js:11:18)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/hadi/Desktop/datachori/node_modules/puppeteer/lib/BrowserFetcher.js:25:20)

推荐答案

它是puppeteer的最新版本.
您的脚本将在较低版本中正常运行.

It occurred to the latest version of puppeteer.
Your scripts will work properly in the lower version.

尝试以下脚本:
npm i -save puppeteer@1.7.0

Try this script:
npm i -save puppeteer@1.7.0

希望对您有帮助.

这篇关于TypeError [ERR_INVALID_ARG_TYPE]:“原始"参数必须是类型为puppeteer node js的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆