Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在请求页面时,如何使JS脚本能够运行';带请求模块的Nodejs中的HTML_Javascript_Html_Node.js_Request - Fatal编程技术网

Javascript 在请求页面时,如何使JS脚本能够运行';带请求模块的Nodejs中的HTML

Javascript 在请求页面时,如何使JS脚本能够运行';带请求模块的Nodejs中的HTML,javascript,html,node.js,request,Javascript,Html,Node.js,Request,我正在尝试使用node.js和请求模块抓取一个网站。到目前为止,我已经能够连接到目标站点并使用来自该站点的查询字符串生成页面的HTML,但我现在意识到该站点使用其站点上的脚本呈现数据 这是我得到的HTML C:\Users\ZHarriott>node test error: null statusCode: 200 body: <!doctype html> <html> <head> <meta charset="utf-8">

我正在尝试使用node.js和请求模块抓取一个网站。到目前为止,我已经能够连接到目标站点并使用来自该站点的查询字符串生成页面的HTML,但我现在意识到该站点使用其站点上的脚本呈现数据

这是我得到的HTML

C:\Users\ZHarriott>node test
error: null
statusCode: 200
body: <!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <link rel="canonical" href="https://bethesda.net">

  <title>Bethesda.net</title>
  <meta name="description" content="The official site for Bethesda, publisher of Fallout, DOOM, Dishonored, Skyrim, Wolfenstein, The Elder Scrolls, more. Your source for news, features & community.">
  <meta name="keywords" content="Fallout,Fallout 4,Fallout 3,Fallout New Vegas,DOOM,Dishonored,Dishonored 2,The Elder Scrolls,The Elder Scrolls Online,The Elder Scrolls Online Tamriel Unlimited,Wolfenstein,Wolfenstein The Old Blood,Wolfenstein The New Order,The Evil Within,The Elder Scrolls V Skyrim,Skyrim,Rage,Brink,Wet,The Elder Scrolls IV Oblivion,Oblivion,Bethesda Game Studios,ZeniMax Online Studios,id Software,Arkane Studios,MachineGames,Machine Games,Tango Gameworks,Bethesda Softworks,Todd Howard">
  <meta name="author" content="">
  <meta property="og:site_name" content="Bethesda.net">
  <meta property="twitter:site" content="@bethesda">
  <meta property="twitter:title" content="Bethesda.net">

  <link href="https://bethesda.net" hreflang="x-default" rel="alternate">
  <link href="https://bethesda.net/en/dashboard" hreflang="en" rel="alternate">
  <link href="https://bethesda.net/de/dashboard" hreflang="de" rel="alternate">
  <link href="https://bethesda.net/es/dashboard" hreflang="es" rel="alternate">
  <link href="https://bethesda.net/fr/dashboard" hreflang="fr" rel="alternate">
  <link href="https://bethesda.net/it/dashboard" hreflang="it" rel="alternate">
  <link href="https://bethesda.net/pl/dashboard" hreflang="pl" rel="alternate">

  <meta name="referrer" content="origin">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">

  <link rel="stylesheet" type="text/css" href="/main.css">
  <script src="https://cdn02.bethesda.net/contentful@3.8.1/browser-dist/contentful.min.js"></script>
</head>
<body>
  <!--[if lte IE 9]>
    <p class="browserupgrade"><h3>You are using an <strong>outdated</strong> browser.</h3></p>
    <p class="browserupgrade">Many things may be non-functional if you continue, please upgrade your browser to improve your experience.</p>
  <![endif]-->
  <noscript>
    <p class="browserupgrade">Please enable javascript to use this site.</p>
    <META HTTP-EQUIV="Refresh" CONTENT="0;URL=nojs.html">
  </noscript>
  <app></app>
  <section id="_bnContent"></section>
  <globalfooter></globalfooter>

  <script>
  // Please do not use www
  if (window.location.hostname === 'www.bethesda.net') {
    window.location.replace('https://bethesda.net/' + window.location.hash)
  }
  try {
    // This ensures the user is using javascript, this is required for bethesda.net
    document.getElementsByTagName('html')[0].classList.remove('no-js')
  } catch (e) {
    console.log(e)
  }
  </script>
  <script src="/sites/main.js"></script>
</body>
</html>


C:\Users\ZHarriott>
C:\Users\ZHarriott>节点测试
错误:null
状态代码:200
正文:
贝塞斯达网

请启用javascript以使用此站点

//请不要使用www 如果(window.location.hostname=='www.bethesda.net'){ window.location.replace('https://bethesda.net/“+window.location.hash) } 试一试{ //这确保了用户使用的是javascript,这是bethesda.net所必需的 document.getElementsByTagName('html')[0].classList.remove('no-js')) }捕获(e){ 控制台日志(e) } C:\Users\ZHarriott>

看起来,因为我实际上没有使用web浏览器,所以该站点在知道如何处理此请求时遇到了问题。对此有何想法?

现在就查看一下。谢谢我会让你知道我发现了什么。现在就检查一下。谢谢我会告诉你我发现了什么。