Ich versuche, die Frage Titel von Stackoverflow Homepage zu greifen. Mein AlbtraumJS-Code unten.nightmarejs document.getElementsByClassName() leeres Objekt zurückgeben
var Nightmare = require('nightmare');
var startingLink = "http://stackoverflow.com"
var nightmare = Nightmare({show:true});
nightmare
.goto(startingLink)
.evaluate(function() {
return document.getElementsByClassName('question-hyperlink')
})
.end()
.then(function(content) {
console.log(content);
})
Es funktioniert, wenn ich in der Chrome-Konsole laufen.
jedoch in nightmareJS ist meine Ausgabe.
ming_o01 (master) nightmare1 $ DEBUG=nightmare node stackoverflow.js
'48': {},
'49': {},
'50': {},
'51': {},
'52': {},
'53': {},
'54': {},
'55': {},
'56': {},
'57': {},
'58': {},
'59': {},
'60': {},
'61': {},
'62': {},
'63': {},
'64': {},
'65': {},
'66': {},
'67': {},
'68': {},
'69': {},
'70': {},
'71': {},
'72': {},
'73': {},
'74': {},
'75': {},
'76': {},
'77': {},
'78': {},
'79': {},
'80': {},
'81': {},
'82': {},
'83': {},
'84': {},
'85': {},
'86': {},
'87': {},
'88': {},
'89': {},
'90': {},
'91': {},
'92': {},
'93': {},
'94': {},
'95': {} }
ming_o01 (master) nightmare1 $
Ich schätze, warum meine Objekte leer sind. Siehe Bild für Screenshot der HTML- und Chrome-Konsole mit Ergebnissen.
Anonymous Downvoter Pflege zu erklären, warum Sie downvoted ?? – thepiercingarrow