【问题标题】:HTTP requests in Meteor package?Meteor 包中的 HTTP 请求?
【发布时间】:2016-04-23 12:02:33
【问题描述】:

我正在尝试使用 http 流星数据包从某个网页中提取元信息,以提取此信息。 如何使用 HTTP meteor 包检索网页中的 meta 关键字和描述?

【问题讨论】:

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


    【解决方案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];
       }
    });
    

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

    【讨论】:

    • @juan-carlos-sanchez-mejia 请接受,如果此解决方案没有解决您的问题,请发表评论
    猜你喜欢
    • 2015-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-23
    • 1970-01-01
    • 2016-08-04
    • 2013-12-21
    • 1970-01-01
    相关资源
    最近更新 更多