Ich habe alles versucht, was ich im Internet finden konnte, aber ich bin nicht in der Lage, Phantomjs auf meinem Ubuntu 14.04 Server arbeiten zu lassen.phantomjs funktioniert nicht mit nodejs
Hier ist mein NodeJS Code-Schnipsel:
phantom.create("--web-security=no", "--ignore-ssl-errors=yes",function(ph) {
return ph.createPage(function(page) {
return page.open(htmlfilepath, function(status) {
page.paperSize = { format: 'A4', orientation: 'portrait', border: '1cm' };
page.render(pdffilepath, function(){
ph.exit();
});
});
});
});
Der Code funktionieren auf meinem lokales System (Mac OS X) in Ordnung. Ich habe phantomjs auf meinem lokalen System mit brauen installiert.
Auf meinem Server installierte ich PhantomJS apt-get verwenden, und es gibt den folgenden Fehler den Sicherheitscode ausgeführt wird:
phantom stderr: Fontconfig warning: ignoring UTF-8: not a valid region tag
und Folgendes wird die Debug-Trace:
phantom stderr: Fontconfig warning: ignoring UTF-8: not a valid region tag [47/205]
phantom stderr: 2016-07-08T02:12:50 [DEBUG] CookieJar - Created but will not store cookies (use option '--cookies-file=<filename>' to enable persisten cookie storage) [45/205]
phantom stderr: 2016-07-08T02:12:50 [DEBUG] Phantom - execute: Configuration [43/205]
2016-07-08T02:12:50 [DEBUG] 0 objectName : "" [42/205]
2016-07-08T02:12:50 [DEBUG] 1 cookiesFile : "" [41/205]
2016-07-08T02:12:50 [DEBUG] 2 diskCacheEnabled : "false" [40/205]
phantom stderr: 2016-07-08T02:12:50 [DEBUG] 3 maxDiskCacheSize : "-1" [38/205]
2016-07-08T02:12:50 [DEBUG] 4 ignoreSslErrors : "true" [37/205]
2016-07-08T02:12:50 [DEBUG] 5 localToRemoteUrlAccessEnabled : "false" [36/205]
2016-07-08T02:12:50 [DEBUG] 6 outputEncoding : "UTF-8" [35/205]
2016-07-08T02:12:50 [DEBUG] 7 proxyType : "http" [34/205]
2016-07-08T02:12:50 [DEBUG] 8 proxy : ":1080" [33/205]
2016-07-08T02:12:50 [DEBUG] 9 proxyAuth : ":" [32/205]
2016-07-08T02:12:50 [DEBUG] 10 scriptEncoding : "UTF-8" [31/205]
2016-07-08T02:12:50 [DEBUG] 11 webSecurityEnabled : "false" [30/205]
2016-07-08T02:12:50 [DEBUG] 12 offlineStoragePath : "" [29/205]
2016-07-08T02:12:50 [DEBUG] 13 offlineStorageDefaultQuota : "-1" [28/205]
2016-07-08T02:12:50 [DEBUG] 14 printDebugMessages : "true" [27/205]
2016-07-08T02:12:50 [DEBUG] 15 javascriptCanOpenWindows : "true" [26/205]
2016-07-08T02:12:50 [DEBUG] 16 javascriptCanCloseWindows : "true" [25/205]
2016-07-08T02:12:50 [DEBUG] 17 sslProtocol : "sslv3" [24/205]
2016-07-08T02:12:50 [DEBUG] 18 sslCertificatesPath : "" [23/205]
[22/205]
phantom stderr: 2016-07-08T02:12:50 [DEBUG] 19 webdriver : ":" [21/205]
2016-07-08T02:12:50 [DEBUG] 20 webdriverLogFile : "" [20/205]
2016-07-08T02:12:50 [DEBUG] 21 webdriverLogLevel : "INFO" [19/205]
2016-07-08T02:12:50 [DEBUG] 22 webdriverSeleniumGridHub : "" [18/205]
2016-07-08T02:12:50 [DEBUG] Phantom - execute: Script & Arguments [17/205]
2016-07-08T02:12:50 [DEBUG] script: "/home/ubuntu/api/node_modules/phantom/shim.js" [16/205]
2016-07-08T02:12:50 [DEBUG] 0 arg: "57128" [15/205]
2016-07-08T02:12:50 [DEBUG] 1 arg: "127.0.0.1" [14/205]
2016-07-08T02:12:50 [DEBUG] Phantom - execute: Starting normal mode [13/205]
[12/205]
phantom stderr: 2016-07-08T02:12:50 [DEBUG] WebPage - setupFrame "" [11/205]
[10/205]
phantom stderr: 2016-07-08T02:12:50 [DEBUG] FileSystem - _open: ":/modules/fs.js" QMap(("mode", QVariant(QString, "r"))) [9/205]
[8/205]
phantom stderr: 2016-07-08T02:12:50 [DEBUG] FileSystem - _open: ":/modules/system.js" QMap(("mode", QVariant(QString, "r"))) [7/205]
[6/205]
phantom stderr: 2016-07-08T02:12:50 [DEBUG] FileSystem - _open: ":/modules/_coffee-script.js" QMap(("mode", QVariant(QString, "r"))) [5/205]
[4/205]
phantom stderr: 2016-07-08T02:12:50 [DEBUG] FileSystem - _open: ":/modules/../coffee-script/package.json" QMap(("mode", QVariant(QString, "r"))) [3/205]
[2/205]
phantom stderr: 2016-07-08T02:12:50 [DEBUG] FileSystem - _open: ":/modules/../coffee-script/./lib/coffee-script/coffee-script.js" QMap(("mode", QVariant(QString, "r"))) [1/205]
[0/205]
phantom stderr: 2016-07-08T02:12:50 [DEBUG] FileSystem - _open: ":/modules/../coffee-script/./lib/coffee-script/./lexer.js" QMap(("mode", QVariant(QString, "r")))
phantom stderr: 2016-07-08T02:12:50 [DEBUG] FileSystem - _open: ":/modules/../coffee-script/./lib/coffee-script/././rewriter.js" QMap(("mode", QVariant(QString, "r")))
phantom stderr: 2016-07-08T02:12:50 [DEBUG] FileSystem - _open: ":/modules/../coffee-script/./lib/coffee-script/././helpers.js" QMap(("mode", QVariant(QString, "r")))
phantom stderr: 2016-07-08T02:12:50 [DEBUG] FileSystem - _open: ":/modules/../coffee-script/./lib/coffee-script/./parser.js" QMap(("mode", QVariant(QString, "r")))
phantom stderr: 2016-07-08T02:12:50 [DEBUG] FileSystem - _open: ":/modules/../coffee-script/./lib/coffee-script/./helpers.js" QMap(("mode", QVariant(QString, "r")))
phantom stderr: 2016-07-08T02:12:50 [DEBUG] FileSystem - _open: ":/modules/../coffee-script/./lib/coffee-script/./nodes.js" QMap(("mode", QVariant(QString, "r")))
phantom stderr: 2016-07-08T02:12:50 [DEBUG] FileSystem - _open: ":/modules/../coffee-script/./lib/coffee-script/././scope.js" QMap(("mode", QVariant(QString, "r")))
phantom stderr: 2016-07-08T02:12:50 [DEBUG] FileSystem - _open: ":/modules/../coffee-script/./lib/coffee-script/./././helpers.js" QMap(("mode", QVariant(QString, "r")))
phantom stderr: 2016-07-08T02:12:50 [DEBUG] FileSystem - _open: ":/modules/../coffee-script/./lib/coffee-script/././lexer.js" QMap(("mode", QVariant(QString, "r")))
phantom stderr: 2016-07-08T02:12:50 [DEBUG] FileSystem - _open: ":/modules/../coffee-script/./lib/coffee-script/./././rewriter.js" QMap(("mode", QVariant(QString, "r")))
phantom stderr: 2016-07-08T02:12:50 [DEBUG] FileSystem - _open: ":/modules/webpage.js" QMap(("mode", QVariant(QString, "r")))
phantom stderr: 2016-07-08T02:12:50 [DEBUG] WebPage - setupFrame "<!--framePath //<!--frame0-->-->"
2016-07-08T02:12:50 [DEBUG] WebPage - updateLoadingProgress: 10
phantom stderr: 2016-07-08T02:12:50 [DEBUG] WebPage - updateLoadingProgress: 11
phantom stderr: 2016-07-08T02:12:50 [DEBUG] Network - Resource request error: 6 ("SSL handshake failed") URL: "https://d1fxtkz8shb9d2.cloudfront.net/sockjs-0.3.min.js"
phantom stderr: 2016-07-08T02:12:50 [DEBUG] WebPage - updateLoadingProgress: 100
phantom stderr: 2016-07-08T02:12:50 [DEBUG] WebPage - setupFrame "<!--framePath //<!--frame1-->-->"
phantom stderr: 2016-07-08T02:12:50 [DEBUG] WebPage - updateLoadingProgress: 10
phantom stderr: 2016-07-08T02:12:50 [DEBUG] WebPage - updateLoadingProgress: 11
phantom stderr: 2016-07-08T02:12:50 [DEBUG] Network - Resource request error: 6 ("SSL handshake failed") URL: "https://d1fxtkz8shb9d2.cloudfront.net/sockjs-0.3.min.js"
phantom stderr: 2016-07-08T02:12:50 [DEBUG] WebPage - updateLoadingProgress: 100
Jede Hilfe, wie dieser Fehler behoben werden kann, wird sehr geschätzt. Vielen Dank.