簡體   English   中英

Google Assistant 的 web 抓取響應出錯

[英]Error in web scraping response for Google Assistant

基本上,我正在嘗試將 web 在此 Dialogflow 意圖中抓取到我的網站。 我正在本地 IDE 中使用節點 js。 但它總是抓住 promise 並在 Google 助理中顯示“myError”。

謝謝你的幫助!

我已經在單獨的節點 js 腳本文件中嘗試了 web 抓取代碼,它工作正常並獲得了期望的結果。 但是,當我將其復制並粘貼到意圖 function 並添加返回(如果不返回我無法部署)時,它會直接進入 promise 的捕獲。

我讀了這篇文章有類似的問題,但沒有工作。 Cheerio.load 與 Google Assistant 的響應相混淆

function mostrarEventos(agent) {
        const cheerio = require('cheerio');
        const rp = require('request-promise');
        // const url = 'https://germantellezv.github.io'
        const options = {
            uri: 'http://germantellezv.github.io/',
            transform: function(body){
                return cheerio.load(body);
            }
        }
        return rp(options)
            .then($ => {
                var result = $('.projects-title').find('p').text()
                agent.add(`${result}`)
                agent.add('hola mundo')
                return console.log('testing'); //irrelevant
            }).catch(err => {
                agent.add('myError')
                return console.log(err) // irrelevant
            })
    }

我希望在谷歌助手中看到我的 web 抓取的結果。 或者至少,了解為什么它不適合 the.then

更新:我嘗試在 .catch 中添加 agent.add(err) 進行更改,現在我在 google 助手中看到:RequestError: Error: getaddrinfo EAI_AGAIN Germantellezv.github.io:80

谷歌雲平台給了我 300 美元來使用他的服務,我用它來 firebase 就是這樣。

最后,我無法向外部 Google 網絡發出請求,因為我的計划是免費的。 現在我正在使用 Blaze 計划,我剛剛看到我的 Google 助手已經成功地進行了 web 抓取。 人們已經說過了,但我沒有在文檔中找到該限制,所以我在這里留下了該信息: https://cloud.google.com/dialogflow/docs/fulfillment-configure

看這個限制項配置履行限制

感謝您的時間和幫助!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM