有没有一种方法可以使用require.js在网页中使用puppeteer?

时间:2020-04-18 22:17:06

标签: javascript web puppeteer scrape

我在网页中使用人偶有问题 我想制作一个Java脚本抓取工具,并将该信息传递给我的index.html页面 我可以用vs代码中的节点来完成它,但不能在浏览器中使用它 当我尝试使用Chrome中的代码时,它说require未定义 所以经过一番挖掘发现我必须使用Require.js,但是我不知道如何使用它 请帮助我

这是我的代码

public class Solution {
    public int jump(int[] A) {
        if (A.length <= 1)
            return 0;
        int maxReach = A[0];
        int step = A[0];
        int jump = 1;
        for (int i = 1; i < A.length; i++) {
            if (i == A.length - 1)
                return jump;
            if (i + A[i] > maxReach)
                maxReach = i + A[i];
            step--;
            if (step == 0) {
                jump++;
                step = maxReach - i;
            }
        }
        return jump;
    }
}

1 个答案:

答案 0 :(得分:2)

否。

require.js库可以让您在Web浏览器中使用CommonJS模块系统。

它不能让您使用Node.js提供的API,但不能使用浏览器提供的API(因此不能让您使用依赖于这些API的模块)。