Meteor包中的HTTP请求?

时间:2016-01-18 10:38:43

标签: node.js http meteor http-headers html-parsing

我正在尝试使用http meteor数据包将元信息从一个网页拉出来,以获取此信息。 如何使用HTTP meteor包在网页中检索meta关键字和描述?

1 个答案:

答案 0 :(得分:1)

示例:

HTTP.call('GET', 'http://example.com', function(err, res){
   if(res.statusCode === 200 && res.content){
      var metaKeywords = /name="keywords" content="(.*)"/gim.exec(res.content)[1];
      var metaDescription = /name="description" content="(.*)"/gim.exec(res.content)[1];
   }
});

您可能需要使用正则表达式。