Node.js Zombie.js浏览器不返回完整的html?

Node.js Zombie.js浏览器不返回完整的html?,node.js,browser,headless,zombie.js,Node.js,Browser,Headless,Zombie.js,我想弄清楚Zombie.js 我有这个剧本: var Browser = require("zombie"); var assert = require("assert"); Browser.visit("http://web.mit.edu", function (e,browser) { console.log(browser.html()); }); 它只是访问页面并记录html,但是我得到的html与我在普通浏览器中得到的源文件不匹配 Zombie.js输出: <html

我想弄清楚Zombie.js

我有这个剧本:

var Browser = require("zombie");
var assert = require("assert");

Browser.visit("http://web.mit.edu", function (e,browser) {
  console.log(browser.html());
});
它只是访问页面并记录html,但是我得到的html与我在普通浏览器中得到的源文件不匹配

Zombie.js输出:

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>MIT - Massachusetts Institute of Technology</title>
    <meta name="keywords" content="Massachusetts Institute of Technology, MIT" />
    <meta name="description" content="MIT is devoted to the advancement of knowledge and education of students in areas that contribute to or prosper in an environment of science and technology." />
    <meta name="robots" content="index,follow,noodp,noydir" />
    <meta name="allow-search" content="yes" />
    <meta name="language" content="en" />
    <meta name="distribution" content="global" />
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="Expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="cache-control" content="no-store" />
    <link rel="canonical" href="http://web.mit.edu" />
    <link rel="image_src" href="http://web.mit.edu/img/MIT_logo.gif" />
    <link rel="search" type="application/opensearchdescription+xml" href="http://web.mit.edu/opensearch.xml" title="MIT - Massachusetts Institute of Technology" />
    <link href="https://plus.google.com/104984516469461796485/" rel="publisher" />
    <!-- icons -->
    <link rel="shortcut icon" href="/favicon.ico" />
    <!-- rss -->
    <link rel="alternate" type="application/rss+xml" title="MIT - Home Page News" href="http://feeds.feedburner.com/mit/news-homepage" />
    <!-- style sheets - global -->
    <link href="styles/style3536.css" rel="stylesheet" type="text/css" media="all" />
    <script src="http://dnn506yrbagrg.cloudfront.net/pages/scripts/0011/6778.js" type="text/javascript"></script>
    <script type="text/javascript" src="http://www.google-analytics.com/ga.js"></script>
    <script type="text/javascript"> 
        var _gaq = _gaq || [];
        _gaq.push(
            ['_setAccount', 'UA-1592615-11'],
            ['_trackPageview','/'],
            ['rollup._setAccount', 'UA-31439876-1'],
            ['rollup._trackPageview', '/mit/www/']
        );
        (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
        })();   
    </script>
    <style type="text/css" media="screen">#flashcontent {visibility:hidden}#flashcontent {visibility:visible}</style>
  </head>
  <body>
    <a href="http://events.mit.edu/">Tuesday, October 23, 2012</a>
  </body>
</html>

麻省理工学院
var _gaq=_gaq | |[];
_推(
[“设置账户”,“UA-1592615-11”],
[u trackPageview','/'],
['rollup._setAccount','UA-31439876-1'],
['rollup._trackPageview','/mit/www/']
);
(功能(){
var ga=document.createElement('script');ga.type='text/javascript';ga.async=true;
ga.src=('https:'==document.location.protocol?'https://ssl' : 'http://www“)+”.google analytics.com/ga.js';
var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(ga,s);
})();   
#flashcontent{可见性:隐藏}#flashcontent{可见性:可见}
真正的来源很长,请在


发生了什么事?

如果您使用
断言
将源代码与僵尸的结果进行比较,您将得到一个错误,原因如下:

首先,
browser.html()

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
源代码向您显示加载它们的代码,而
zombie
向您提供结果

<script src="http://dnn506yrbagrg.cloudfront.net/pages/scripts/0011/6778.js" type="text/javascript"></script>


根据这些脚本的内容,它们可能会进一步更改DOM,而僵尸会显示更多的偏差。不幸的是,我不知道有什么解决办法

var _gaq = _gaq || [];
_gaq.push(
  ['_setAccount', 'UA-1592615-11'],
  ['_trackPageview','/'],
  ['rollup._setAccount', 'UA-31439876-1'],
  ['rollup._trackPageview', '/mit/www/']
);
(function() {
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();   
<script src="http://dnn506yrbagrg.cloudfront.net/pages/scripts/0011/6778.js" type="text/javascript"></script>
<script type="text/javascript" src="http://www.google-analytics.com/ga.js"></script>