为什么我的videos的信息获取不到?
function filterChapters(html){ var $ =cheerio.load(html); var chapters = $('.chapter-active'); var title =$('.path span').text(); var number = parseInt($('.js-learn-num').text().trim(),10); var courseData ={ title:title, number:number, videos:[] }; chapters.each(function(item){ var chapter =$(this); var temp =chapter.find('strong'); var chapterTitles =[]; temp.contents().each(function(){ if(this.nodeType === 3){ chapterTitles.push(this.wholeText); } }); var chapterTitle = chapterTitles[1]; var videos = chapter.find('video').children('li'); var chapterData = { chapterTitle:chapterTitle, videos:[] } videos.each(function(item){ var video =$(this); var videotemp = $(this).find('a').contents(); var videoTitle =''; videotemp.each(function(){ if(this.nodeType === 3){ videoTitle = this.wholeText; } }) var id = video.$('a').attr('href').split('video/')[1]; chapterData.videos.push({ title:videoTitle, id:id }) }) courseData.videos.push(chapterData); }) return courseData; }
不知道哪里出问题了,就是videos.each循环这个不执行,获取不到video标签里的信息