我试图从HP打印机中清除打印日志。页面内容无法加载。以下错误是一个线索,但我不确定我是否知道如何规避它。
<noscript> <div id="pgm-no-js-text"> <p>JavaScript is
required to access this website.</p>
<p>Please enable JavaScript or use a browser that supports
JavaScript.</p> </div> </noscript>
以下是我使用
的代码var url =''; // printer web interface IP, tried http:// and https://
var page = require('webpage').create();
console.log("klik 0");
page.settings.userAgent = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36';
//page.settings.javascriptEnabled = true;
//page.viewportSize = { width: 1920, height: 1080 };
page.onLoadFinished = function() {
console.log("### finished loading page");
};
page.open(url, function(status) {
setTimeout(function() {
console.log("Status: " + status);
if (status === "success") {
console.log("klik1 OK");
console.log(page.content);
phantom.exit(1);
} else {
console.log("eeeek, no go");
phantom.exit();
}
}, 3000);
});
是否可以在页面上实现额外的.js脚本(大小为600 kb)
<script src="./HP Officejet Pro X476dw MFP_files/Unified.js" type="text/javascript"></script>
以某种方式阻止我手动加载页面?如果我通过page.render
制作屏幕截图,但它只加载部分背景而不是其他内容。关于我如何自己调试这个问题的任何提示都将非常感激。
我执行phantomjs --debug=true script.js
时的详细调试输出。在Ubuntu 16.04上,PhantomJS的版本是2.1.1。
2017-03-24T15:35:17 [DEBUG] CookieJar - Created but will not store cookies (use option '--cookies-file=<filename>' to enable persistent cookie storage)
2017-03-24T15:35:17 [DEBUG] Set "http" proxy to: "" : 1080
2017-03-24T15:35:17 [DEBUG] Phantom - execute: Configuration
2017-03-24T15:35:17 [DEBUG] 0 objectName : ""
2017-03-24T15:35:17 [DEBUG] 1 cookiesFile : ""
2017-03-24T15:35:17 [DEBUG] 2 diskCacheEnabled : "false"
2017-03-24T15:35:17 [DEBUG] 3 maxDiskCacheSize : "-1"
2017-03-24T15:35:17 [DEBUG] 4 diskCachePath : ""
2017-03-24T15:35:17 [DEBUG] 5 ignoreSslErrors : "false"
2017-03-24T15:35:17 [DEBUG] 6 localUrlAccessEnabled : "true"
2017-03-24T15:35:17 [DEBUG] 7 localToRemoteUrlAccessEnabled : "false"
2017-03-24T15:35:17 [DEBUG] 8 outputEncoding : "UTF-8"
2017-03-24T15:35:17 [DEBUG] 9 proxyType : "http"
2017-03-24T15:35:17 [DEBUG] 10 proxy : ":1080"
2017-03-24T15:35:17 [DEBUG] 11 proxyAuth : ":"
2017-03-24T15:35:17 [DEBUG] 12 scriptEncoding : "UTF-8"
2017-03-24T15:35:17 [DEBUG] 13 webSecurityEnabled : "true"
2017-03-24T15:35:17 [DEBUG] 14 offlineStoragePath : ""
2017-03-24T15:35:17 [DEBUG] 15 localStoragePath : ""
2017-03-24T15:35:17 [DEBUG] 16 localStorageDefaultQuota : "-1"
2017-03-24T15:35:17 [DEBUG] 17 offlineStorageDefaultQuota : "-1"
2017-03-24T15:35:17 [DEBUG] 18 printDebugMessages : "true"
2017-03-24T15:35:17 [DEBUG] 19 javascriptCanOpenWindows : "true"
2017-03-24T15:35:17 [DEBUG] 20 javascriptCanCloseWindows : "true"
2017-03-24T15:35:17 [DEBUG] 21 sslProtocol : "default"
2017-03-24T15:35:17 [DEBUG] 22 sslCiphers : "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA:...-RSA-AES128-SHA:DHE-DSS-AES128-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:RC4-SHA:RC4-MD5"
2017-03-24T15:35:17 [DEBUG] 23 sslCertificatesPath : ""
2017-03-24T15:35:17 [DEBUG] 24 sslClientCertificateFile : ""
2017-03-24T15:35:17 [DEBUG] 25 sslClientKeyFile : ""
2017-03-24T15:35:17 [DEBUG] 26 sslClientKeyPassphrase : ""
2017-03-24T15:35:17 [DEBUG] 27 webdriver : ":"
2017-03-24T15:35:17 [DEBUG] 28 webdriverLogFile : ""
2017-03-24T15:35:17 [DEBUG] 29 webdriverLogLevel : "INFO"
2017-03-24T15:35:17 [DEBUG] 30 webdriverSeleniumGridHub : ""
2017-03-24T15:35:17 [DEBUG] Phantom - execute: Script & Arguments
2017-03-24T15:35:17 [DEBUG] script: "ws.js"
2017-03-24T15:35:17 [DEBUG] Phantom - execute: Starting normal mode
2017-03-24T15:35:17 [DEBUG] WebPage - setupFrame ""
2017-03-24T15:35:17 [DEBUG] FileSystem - _open: ":/modules/fs.js" QMap(("mode", QVariant(QString, "r")))
2017-03-24T15:35:17 [DEBUG] FileSystem - _open: ":/modules/system.js" QMap(("mode", QVariant(QString, "r")))
2017-03-24T15:35:17 [DEBUG] FileSystem - _open: ":/modules/webpage.js" QMap(("mode", QVariant(QString, "r")))
klik 0
2017-03-24T15:35:17 [DEBUG] WebPage - updateLoadingProgress: 10
2017-03-24T15:35:17 [DEBUG] CookieJar - Saved "sid=-a79d467495756243f01f3edf9eba7bbd; domain=; path=/"
2017-03-24T15:35:17 [DEBUG] WebPage - updateLoadingProgress: 30
2017-03-24T15:35:17 [DEBUG] WebPage - updateLoadingProgress: 35
2017-03-24T15:35:17 [DEBUG] WebPage - updateLoadingProgress: 37
2017-03-24T15:35:17 [DEBUG] WebPage - updateLoadingProgress: 40
2017-03-24T15:35:17 [DEBUG] WebPage - updateLoadingProgress: 42
2017-03-24T15:35:17 [DEBUG] WebPage - updateLoadingProgress: 45
2017-03-24T15:35:17 [DEBUG] WebPage - updateLoadingProgress: 47
2017-03-24T15:35:17 [DEBUG] WebPage - updateLoadingProgress: 49
2017-03-24T15:35:17 [DEBUG] WebPage - setupFrame ""
2017-03-24T15:35:17 [DEBUG] WebPage - setupFrame "<!--framePath //<!--frame0-->-->"
2017-03-24T15:35:17 [DEBUG] WebPage - updateLoadingProgress: 50
2017-03-24T15:35:17 [DEBUG] WebPage - updateLoadingProgress: 50
2017-03-24T15:35:18 [DEBUG] WebPage - updateLoadingProgress: 52
2017-03-24T15:35:18 [DEBUG] WebPage - updateLoadingProgress: 56
2017-03-24T15:35:18 [DEBUG] WebPage - updateLoadingProgress: 59
2017-03-24T15:35:18 [DEBUG] WebPage - updateLoadingProgress: 62
2017-03-24T15:35:18 [DEBUG] WebPage - updateLoadingProgress: 65
2017-03-24T15:35:18 [DEBUG] WebPage - updateLoadingProgress: 68
2017-03-24T15:35:18 [DEBUG] WebPage - updateLoadingProgress: 70
2017-03-24T15:35:18 [DEBUG] WebPage - updateLoadingProgress: 73
2017-03-24T15:35:18 [DEBUG] WebPage - updateLoadingProgress: 75
2017-03-24T15:35:18 [DEBUG] WebPage - updateLoadingProgress: 77
2017-03-24T15:35:18 [DEBUG] WebPage - updateLoadingProgress: 79
2017-03-24T15:35:18 [DEBUG] WebPage - updateLoadingProgress: 81
2017-03-24T15:35:18 [DEBUG] WebPage - updateLoadingProgress: 84
2017-03-24T15:35:18 [DEBUG] WebPage - updateLoadingProgress: 86
2017-03-24T15:35:18 [DEBUG] WebPage - updateLoadingProgress: 88
2017-03-24T15:35:18 [DEBUG] WebPage - updateLoadingProgress: 90
2017-03-24T15:35:18 [DEBUG] WebPage - updateLoadingProgress: 100
### finished loading page
2017-03-24T15:35:18 [DEBUG] WebPage - setupFrame ""
Status: success
klik1 OK
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="/framework/Unified.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
frameWorkObj = {};
frameWorkObj.pkg = "ews";
</script>
... abbreviated content...
// frame buster
if(top != self)
top.location.replace(self.location.href);
</script>
<noscript>
<div id="pgm-no-js-text">
<p>JavaScript is required to access this website.</p>
<p>Please enable JavaScript or use a browser that supports JavaScript.</p>
</div>
</noscript>
<div id="ui-datepicker-div" style="display: none;"></div><div id="tooltip" style="display: none;"><div><div id="background"><img src="/images/framework/tooltip_bg.png"></div><div id="content"><h3></h3><div class="body"></div><div class="url"></div></div></div></div></body></html>
2017-03-24T15:35:21 [DEBUG] WebPage - setupFrame ""
2017-03-24T15:35:21 [DEBUG] WebPage - updateLoadingProgress: 10
2017-03-24T15:35:21 [DEBUG] WebPage - setupFrame ""
2017-03-24T15:35:21 [DEBUG] WebPage - updateLoadingProgress: 100
2017-03-24T15:35:21 [DEBUG] WebPage - setupFrame ""
2017-03-24T15:35:21 [DEBUG] FileSystem - _open: ":/modules/fs.js" QMap(("mode", QVariant(QString, "r")))
2017-03-24T15:35:21 [DEBUG] FileSystem - _open: ":/modules/system.js" QMap(("mode", QVariant(QString, "r")))
2017-03-24T15:35:21 [DEBUG] FileSystem - _open: ":/modules/webpage.js" QMap(("mode", QVariant(QString, "r")))
2017-03-24T15:35:21 [DEBUG] WebPage - updateLoadingProgress: 10
2017-03-24T15:35:21 [DEBUG] WebPage - setupFrame ""
2017-03-24T15:35:21 [DEBUG] FileSystem - _open: ":/modules/fs.js" QMap(("mode", QVariant(QString, "r")))
2017-03-24T15:35:21 [DEBUG] FileSystem - _open: ":/modules/system.js" QMap(("mode", QVariant(QString, "r")))
2017-03-24T15:35:21 [DEBUG] FileSystem - _open: ":/modules/webpage.js" QMap(("mode", QVariant(QString, "r")))
2017-03-24T15:35:21 [DEBUG] WebPage - updateLoadingProgress: 100
2017-03-24T15:35:21 [DEBUG] CookieJar - Purged (session) "sid=sd5607228-a793edf9eba7bbd; domain=; path=/"