解决方法
考虑使用
cheerio它就像jquery,但更多的是刮.我以前试过回答这个问题,所以我希望这次能做得更好.
它的一个npm模块,所以第一步安装它(在您的项目目录中)与终端:
- meteor add http
- cd .meteor
- npm install cheerio
那么现在的代码:
您需要在您的服务器js /或等效项中使用它
- var cheerio = __meteor_bootstrap__.require('cheerio');
- Meteor.methods({
- last_action: function() {
- $= cheerio.load(Meteor.http.get("https://github.com/meteor/meteor").content);
- return $('.commit-title').text().trim()
- }
- })
如果您从客户端js运行,您将看到流星github分支上的最后一个操作:
- Meteor.call("last_action",function(err,result){ console.log(result) } );
我今天到了/ feb 23rd
与github.com/meteor/meteor相同