Tag: 啦啦队

在每个循环内调用cheerio.load

所以Meteor的基本服务器JS scrapper。 这种模式很简单。 脚本find某些链接,然后从它们加载内容并将内容存储在variables中。 在循环中加载cheerio时脚本不断崩溃。 渔获在哪里? 什么是最好的实现这个目的? Meteor.methods({ loadPage: function () { result = Meteor.http.get("http://url.com"); $ = cheerio.load(result.content); $('.class').each(function(i,elem){ var link = $(this).attr('href'); var title = $(this).text(); var $ = cheerio.load(Meteor.http.get(link).content); var postContent = $('.classOnLoadedPage'); Images.insert( { link: link, title: title, postContent: postContent }); }); } });