gpt4 book ai didi

node.js - 从 Nightmare 请求中获取评估数据和数据Cookie

转载 作者:行者123 更新时间:2023-12-03 13:23:40 26 4
gpt4 key购买 nike

如何在一个 Nightmare 请求中提出一个请求以获取document.titlecookies

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)

最佳答案

这有效:

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}
}

关于node.js - 从 Nightmare 请求中获取评估数据和数据Cookie,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47323843/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com