I'm crawling a page where I type()
something in an input field, click()
a button and then wait()
for some element to appear.
I would like to get all the headers for the POST request that is fired after click()
.
I see that goto()
returns the headers, but I don't think I can use it in my case because after click()
I stay on the same page.
Here is an example of my code on another test page (I would like to get the POST request headers after wait()
):
var Nightmare = require('nightmare');
var nightmare = Nightmare({ show: true });
nightmare
.goto('https://jigsaw.w3.org/HTTP/300/')
.click('tbody tr:nth-child(5) td form input[type=submit]')
.wait('body p:nth-of-type(3)')
.evaluate(function () {
return document.querySelector('body p:nth-of-type(3)').innerText;
})
.end()
.then(function (result) {
console.log(result);
})
.catch(function (error) {
console.error('Search failed:', error);
});
Note: I use Nightmare 2.10.0 and Node.js 8.1.3.