node寫了的小爬蟲,用cheerio解析爬取到的數(shù)據(jù)封裝寫入時(shí)候報(bào)錯(cuò)了,說是循環(huán)調(diào)用的問題,貼代碼: $('#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的是每個(gè)li, 我想在room_label 里放幾個(gè)爬到的文字標(biāo)簽, 然后就想著用map來遍歷一個(gè)數(shù)組回來,結(jié)果就報(bào)錯(cuò)了,說是循環(huán)調(diào)用,去掉這個(gè)map可以正常運(yùn)行,想問下究竟為什么不能這樣嵌套使用遍歷方法?報(bào)錯(cuò)圖:
1 回答

汪汪一只貓
TA貢獻(xiàn)1898條經(jīng)驗(yàn) 獲得超8個(gè)贊
room_label: _this.find('.impress-tag-item').toArray().map((i, ele) => { return $(this).text() })
- 1 回答
- 0 關(guān)注
- 1848 瀏覽
添加回答
舉報(bào)
0/150
提交
取消