I
I
Ilia Malashko2020-04-03 13:27:32
ubuntu
Ilia Malashko, 2020-04-03 13:27:32

Why is Nightmare.js not returning a result?

Hello.

I decided to master Nightmare.js for parsing dynamic content from sites.
I mostly work in php, from node.js to "you".

I installed nvm, node.js and nightmare.js itself, created the index.js file, tested the script, everything is fine.
From https://github.com/segmentio/nightmare took an example:

const Nightmare = require('nightmare')
const nightmare = Nightmare({ show: true })

nightmare
  .goto('https://duckduckgo.com')
  .type('#search_form_input_homepage', 'github nightmare')
  .click('#search_button_homepage')
  .wait('#r1-0 a.result__a')
  .evaluate(() => document.querySelector('#r1-0 a.result__a').href)
  .end()
  .then(console.log)
  .catch(error => {
    console.error('Search failed:', error)
  })

returns nothing:
5e870ec24a2fb821905721.png
The nightmare object outputs:
var Nightmare = require('nightmare');
var nightmare = Nightmare({ show: true });

console.log(nightmare);

5e870f22038dd291952290.png

I tried to google this problem, but apparently everything should work immediately after installation, no additional. settings are not required, what did I do wrong?

Maybe I didn't install some package that is considered obvious to those who work in node.
I installed npm, node.js, Nightmare.js and electron. Maybe something else needs to be put to work?
Maybe I'm waiting for the output in the console, but the output needs a headless browser? Or some other nuance?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Ronald McDonald, 2019-09-25
@vessels

This is the trouble with Linux, it is barely on the desktop, and you are on a laptop.
What is the laptop model? Does everything work in Live mode? Which of "all" distributions have you tried? Have you tried Fedora? What does it show airmon-ng?

I
Ilia Malashko, 2020-04-09
@miv-men

It turned out that Nightmare has outlived its usefulness, it does not work in node 8+ and with a fresh electron.
As an analogue, you can use puppeteer

S
Shohruh Shaimardonov, 2020-04-03
@joeberetta

Pay attention to the line with .then(console.log)
I assume that there should be something like this:
.then(res => console.log(res))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question