getCertificatesFromPage

getCertificatesFromPage

我有这样的话:

async.mapLimit(urls, 10, getCertificatesFromPage, callback)


其中urls是具有urls的数组,getCertificatesFromPage:

getCertificatesFromPage = (url, callback) ->
  request url, (err, res, html) ->
    $ = cheerio.load(html)
    allRows = $('div.search-result-shop')

    objCollector = []

    allRows.each () ->
      links = $(this).find('a')

      obj =
        companyName: $(this).find('.companyname').text()
        pageDetailsUrl: ''
        link: ''

      for link in links
        extractedLink = link.attribs.href
        if extractedLink.includes('http')
          obj.link = extractedLink
        else
          obj.pageDetailsUrl = nameSpace.pageName + extractedLink
      objCollector.push obj
    return objCollector


这不能很好地工作,因为我需要从每页10到10页收集所有对象,但是我只收到50 * 10链接,还有更多

如何使用此代码使其有效?

最佳答案

getCertificatesFromPage = (url, callback) ->


您没有在callback函数中调用getCertificatesFromPage。否则,框架将无法知道工作何时完成。

07-28 10:14