使用 cheerio 获取所有包含的 js

Fetch all the js included using cheerio

使用 cheerio 获取网站中包含的所有 js。 我正在获取此 URL https://www.anandtech.com/,当我在网页控制台中使用代码时,它会获取网页中包含的所有 js。

$("script[src]").each(function(i, src) {
    console.log($(this).attr("src")); 
});

但无法使用 cheerio 获取所有 js。它只获取很少的网址。

给你!

$("script").map((i,$el) => {
  if($(this).attr("src")){
    console.log($(this).attr("src"))
  }else{
    let text = $($el).text()
    console.log(text)
  }
})