我正在抓取页面,其中某个输入字段是type()
,click()
是某个按钮,然后是wait()
以显示某个元素。在Nightmare JS中单击()和wait()之后获取POST请求标头
我想获得的是click()
后被解雇POST请求的所有头。
我看到goto()
返回标题,但我不认为我可以使用它在我的情况下,因为在click()
我留在同一页面上。
这里是我的另一个测试页面代码的一个例子(我想wait()
后拿到POST请求头):
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);
});
注:我用的噩梦2.10.0和Node.js的8.1。 3。