我刚刚测试了Zombie.js,让它访问StackOverflow上的登录页面。我的代码如下:
var Browser = require("zombie");
// Load the page from localhost
browser = new Browser()
browser.visit("http://stackoverflow.com/users/login/", function () {
browser.wait(3000, function (){
console.log(browser.html());
console.log(browser.success);
});
});我试着四处看看,我知道Zombie.js运行脚本并对HTML进行某种程度的压缩,但在本例中,代码的整个body都丢失了。
我不认为这是相关的,但是返回的代码是:
<html><head>
<title>Log In - Stack Overflow</title>
<link rel="shortcut icon" href="http://cdn.sstatic.net/stackoverflow/img/favicon.ico" />
<link rel="apple-touch-icon" href="http://cdn.sstatic.net/stackoverflow/img/apple-touch-icon.png" />
<link rel="search" type="application/opensearchdescription+xml" title="Stack Overflow" href="/opensearch.xml" />
<script type="text/javascript" src="http://www.google-analytics.com/ga.js"></script><script type="text/javascript" src="http://edge.quantserve.com/quant.js"></script><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="http://cdn.sstatic.net/js/stub.js?v=8a629d6e9fb6"></script>
<link rel="stylesheet" type="text/css" href="http://cdn.sstatic.net/stackoverflow/all.css?v=24fdd40e5473" />
<meta http-equiv="X-XRDS-Location" content="http://stackoverflow.com/yadis" />
<script src="http://cdn.sstatic.net/Js/third-party/openid-jquery.js?v=8b3167d0ee55" type="text/javascript"></script>
<script type="text/javascript">
document.write('<style type="text/css">.login-page .script-only { display: block; }<\/style>');
$(function() {
openid.init('openid_identifier', '', 'http://cdn.sstatic.net/Img/openid/openid-logos.png?v=8', true);
});
</script>
<script type="text/javascript">
StackExchange.init({"stackAuthUrl":"https://stackauth.com","serverTime":1353439370,"styleCode":true,"enableUserHovercards":true,"site":{"name":"Stack Overflow","description":"Q&A for professional and enthusiast programmers","isNoticesTabEnabled":true,"recaptchaPublicKey":"6LdchgIAAAAAAJwGpIzRQSOFaO0pU6s44Xt8aTwc","enableSocialMediaInSharePopup":true},"user":{"fkey":"8074e87bcb0a1a15cc69db799d304930","isAnonymous":true}});
StackExchange.using.setCacheBreakers({"js/prettify-full.js":"c862bf93b3ec","js/moderator.js":"37bba549a03e","js/full-anon.js":"bcd6f2e0d542","js/full.js":"87618162bac4","js/wmd.js":"89ec12ce09df","js/third-party/jquery.autocomplete.min.js":"e5f01e97f7c3","js/mobile.js":"6eb68240242f","js/help.js":"fc9fb0517db2","js/tageditor.js":"450c9e8426fc","js/tageditornew.js":"9ac6c13a3a7f","js/inline-tag-editing.js":"30f72b99548b","js/revisions.js":"8c6bcd93b7fe","js/review.js":"37dd8dc83788"});
</script>
</head>
<body class="login-page" style="cursor: default;"><style type="text/css">.login-page .script-only { display: block; }</style></body></html>编辑:刚刚注意到这可能是由页面脚本中的document.write调用造成的。
发布于 2012-11-20 19:40:38
使用浏览器的runScripts: false选项修复了这个问题,因为document.write覆盖了主体。
我打开关于他们的吉萨布的问题是因为这不是其他浏览器显示的行为。
https://stackoverflow.com/questions/13480655
复制相似问题