账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    koa2 UnhandledPromiseRejectionWarning
    24
    0
    1. 运行下面代码后报错,不知道怎么修改,望大神指出错误点。
    2. 报错
    (node:2920) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejec
    tion id: 1): Error: Navigation Timeout Exceeded: 30000ms exceeded
    (node:2920) [DEP0018] DeprecationWarning: Unhandled promise rejections are depre
    cated. In the future, promise rejections that are not handled will terminate the
     Node.js process with a non-zero exit code.
    1. 代码如下
    const puppeteer = require('puppeteer')
    
    const url = `https://movie.douban.com/tag/#/?sort=R&;range=6,10&tags=%E7%94%B5%E5%BD%B1,%E6%BE%B3%E5%A4%A7%E5%88%A9%E4%BA%9A`
    
    const sleep = time => new Promise(resolve => {
      setTimeout(resolve, time)
    })
    
    ;(async () => {
      console.log('Start visit the target page')
    
      const browser = await puppeteer.launch({
        args: ['--no-sandbox'],
        dumpio: false
      })
    
      const page = await browser.newPage()
      await page.goto(url, {
        waitUntil: 'networkidle2'
      })
    
      await sleep(3000)
    
      await page.waitForSelector('.more')
    
      for (let i = 0; i < 2; i++) {
        await sleep(3000)
        await page.click('.more')
      }
    
      const result = await page.evaluate(() => {
        var $ = window.$
        var items = $('.list-wp a')
        var links = []
    
        if (items.length >= 1) {
          items.each((index, item) => {
            let it = $(item)
            let doubanId = it.find('div').data('id')
            let title = it.find('.title').text()
            let rate = Number(it.find('.rate').text())
            let poster = it.find('img').attr('src').replace('s_ratio', 'l_ratio')
    
            links.push({
              doubanId,
              title,
              rate,
              poster
            })
          })
        }
    
        return links
      })
    
      browser.close()
    
      process.send({result})
      process.exit(0)
    })()
    0
    打赏
    收藏
    点击回答
        全部回答
    • 共 0 条
    • 玄销骨立 普通会员 1楼
      502 Bad Gateway

      502 Bad Gateway


      nginx
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部