简体   繁体   English

将 Nightmare.js 应用程序部署到 Heroku(Node.js + Telegraf)

[英]Deploying Nightmare.js App To Heroku (Node.js + Telegraf)

I want to deploy my app to heroku which contains web scraping using nightmare.js and my app doesn't work when deployed.我想将我的应用程序部署到 heroku,其中包含使用 nightmare.js 的网络抓取,并且我的应用程序在部署时不起作用。 What is the problem?问题是什么? Here is the basic code...这是基本代码...

bot.on('text', async (ctx) => {
  try{

    
    var input = ctx.message.text

    const def1 = await nightmare

      .goto('https://www.google.com/')
      
      .type('#term' ,input)
      .type('#term', '\u000d')
      
      .wait(200)

      .click('#rso > div:nth-child(1) > div > div.r > a > h3')

      .wait(200)

      .evaluate(() => document.querySelector('#content > div:nth-child(1) > div.meaning').textContent)
      
      // .end()
      // .then(console.log)

      .catch(err => {
        console.error(err)
      })


    console.log('def1 == ' + def1)
    
    await ctx.reply(def1)

  }

  catch(err){
    console.error(err)
  }


}) 

I have left out some basic require and init statements to make the code look simpler.我省略了一些基本的 require 和 init 语句以使代码看起来更简单。 And it doesn't have front end.而且它没有前端。 it's all back end.都是后端。

when i host it on heroku it does nothing.当我在 heroku 上托管它时,它什么也不做。 it says 'clean exit - waiting for changes'.它说“干净退出 - 等待更改”。

so what can i do to deploy my app to heroku?那么我该怎么做才能将我的应用程序部署到 heroku?

Please provide more information:请提供更多信息:

  • Have you set "engines" in package.json?您是否在 package.json 中设置了“引擎”?
  • What exactly does the heroku log say? heroku 日志到底说了什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM