V
V
Vladimir2021-09-08 18:46:32
Parsing
Vladimir, 2021-09-08 18:46:32

Why can't the parser even find the body on the page?

Hello. Can you please tell me why the selection by tag may not work in my case? Whatever I choose, I always get an empty object. If I try innerHTML - I get instead of an empty html body object.

function getPage(url, proxy) {
    const nightmare = Nightmare({
        show: true,
        switches: {
            'proxy-server': proxy[Math.floor(Math.random() * proxy.length)],
            'ignore-certificate-errors': false
        },
    });
    return nightmare
        .authentication('888', '8888')
        .goto(url)
        .evaluate(() => {
            return [document.querySelector('ul')];
        })
        .then(data => console.log(data)) // [ {} ]
}


PS:

.evaluate(() => {
            return document.body; // {}
        })


Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Chipekwe, 2021-09-08
@XanXanXan

Most likely the site is a SPA based on some react and the house was simply not built at the time of the request.
The documentation has a method .wait()for waiting for the necessary elements to appear.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question