如何在一场噩梦请求中提出一个请求以获取document.title
和cookies
?
const Nightmare = require('nightmare')
Nightmare()
.goto('http://cnn.com')
.evaluate(() => document.title)
.end()
.then(console.log)
Nightmare()
.goto('http://cnn.com')
.cookies.get()
.end()
.then(console.log)
答案 0 :(得分:0)
这有效:
const Nightmare = require('nightmare')
const nightmare = Nightmare()
async function example () {
const call = nightmare
.goto('http://cnn.com')
const title = await call
.evaluate(() => document.title)
const cookies = await call
.cookies.get()
await call.end()
return {title, cookies}
}