【发布时间】:2016-11-27 19:25:12
【问题描述】:
我在文档中看到的示例在使用 .then() 之前调用 .end()。 比如
nightmare
.goto('http://yahoo.com')
.type('form[action*="/search"] [name=p]', 'github nightmare')
.click('form[action*="/search"] [type=submit]')
.wait('#main')
.evaluate(function () {
return document.querySelector('#main .searchCenterMiddle li a').href
})
.end()
.then(function (result) {
console.log(result)
})
.catch(function (error) {
console.error('Search failed:', error);
});
但是,我正在尝试这样做......
...
.then(function () {...})
.end()
但我收到一条错误消息,指出 .end 不存在。
我也尝试了下面的方法,它不会抛出错误但会导致噩梦挂起。
...
.then(function () {...})
.then(function () {
nightmare.end()
});
【问题讨论】:
标签: javascript node.js web-scraping nightmare