【发布时间】:2016-04-23 12:02:33
【问题描述】:
我正在尝试使用 http 流星数据包从某个网页中提取元信息,以提取此信息。 如何使用 HTTP meteor 包检索网页中的 meta 关键字和描述?
【问题讨论】:
标签: node.js http meteor http-headers html-parsing
我正在尝试使用 http 流星数据包从某个网页中提取元信息,以提取此信息。 如何使用 HTTP meteor 包检索网页中的 meta 关键字和描述?
【问题讨论】:
标签: node.js http meteor http-headers html-parsing
例子:
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];
}
});
您可能需要使用正则表达式。
【讨论】: