在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/網(wǎng)絡安全  HTML/ 怎么在cheerio獲得的數(shù)據(jù)中嵌套使用遍歷方法?

怎么在cheerio獲得的數(shù)據(jù)中嵌套使用遍歷方法?

node寫了的小爬蟲,用cheerio解析爬取到的數(shù)據(jù)封裝寫入時候報錯了,說是循環(huán)調用的問題,貼代碼:

    $('#live-list-contentbox>li').each((i, ele) => {
        let _this = $(ele);
        rooms.push({
            title: _this.find('.play-list-link').attr('title'),
            author: _this.find('.dy-name').text(),
            room_num: _this.find('.play-list-link').attr('href').replace(/\//g, ''),
            room_label: _this.find('.impress-tag-item').map((i, ele) => {
                return $(this).text()
            })
        });
    });

上面最外層each的是每個li, 我想在room_label 里放幾個爬到的文字標簽, 然后就想著用map來遍歷一個數(shù)組回來,結果就報錯了,說是循環(huán)調用,去掉這個map可以正常運行,想問下究竟為什么不能這樣嵌套使用遍歷方法?

報錯圖:
clipboard.png

回答
編輯回答
愛是癌
            room_label: _this.find('.impress-tag-item').toArray().map((i, ele) => {
                return $(this).text()
            })
2018年3月9日 07:38