简体   繁体   中英

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. 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. And it doesn't have front end. it's all back end.

when i host it on heroku it does nothing. it says 'clean exit - waiting for changes'.

so what can i do to deploy my app to heroku?

Please provide more information:

  • Have you set "engines" in package.json?
  • What exactly does the heroku log say?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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