javascript - 在 google dialogflow fullfilment 中使用 node.js 文档未定义(服务器端)
问题描述
function readrequestfromdb(agent){
var links = [];
var requestbooks = [];
var books = admin.database().ref( 'data/request' );
const Nightmare = require( 'nightmare' );
const nightmare = Nightmare();
const url = 'https://www.flipkart.com/';
return books.once( "value", function( data ){
var _data = data.val();
for( var key in _data ){
var book = _data[key];
var name = book.name;
var author = book.author;
var res = `name is ${name} and author is ${author}`;
requestbooks.push( res );
nightmare
.goto( url )
.wait( 'body' )
.click( 'button._2AkmmA._29YdH8' )
.type( 'input.LM6RPg', name )
.click( 'button.vh79eN' )
.wait( 'div.bhgxx2' )
.evaluate( () => document.querySelectorAll( 'a._2cLu-l' )[0].href )
.end()
.then( link => {
console.log( link );
links.push( link );
} )
.catch( err => {
console.log( err );
} );
}
return agent.add( text );
} );
}
我正在尝试使用上述代码进行网络抓取,并且在噩梦文档中给出了访问文档。什么是解决方案。
解决方案
推荐阅读
- java - 单击主页按钮时如何将活动重定向到其先前的活动
- mysql - Illuminate \ Database \ QueryException (HY000) SQLSTATE[HY000]:一般错误:1364 字段“verifyToten”没有默认值
- facebook - ionic3:错误:未捕获(承诺):错误:没有 Facebook 提供者
- python - Heroku 部署 - 2 个 github 项目
- python - 使用 for 循环迭代并引用 lst[i] 时的 TypeError/IndexError
- serverless-framework - 如何使用 excludeDevDependencies?
- java - 用 java 解析 {“item”=“value”}
- c# - How to run same test class parallel in c#
- java - Java中的并发编程。试图模拟一组收银台
- php - Laravel:登录后如何正确重定向到多重身份验证