使用Node.js获取外部网站内容

4
在我的网站中,我使用Node.js作为后端,HTML作为前端。 我需要获取外部网站的元数据(关键字)。
有没有用于在Node.js中获取元数据的包?
例如,我有一个数组中包含100个网站的URL,格式如下。
var arrayName = ["http://www.realsimple.com/food-recipes/9-healthy-predinner-snacks", "http://www.womenshealthmag.com/weight-loss/100-calorie-snacks", "https://www.pinterest.com/explore/healthy-snacks/", "http://www.rd.com/slideshows/healthy-snacks-for-adults/", "http://greatist.com/snacking", "http://www.bodybuilding.com/fun/26-best-healthy-snacks.html"]

我需要获取所有网站元数据,特别是元数据中的关键字。在node js中是否有相关的包?

我在谷歌上找到了一些代码。

var options = {
host: 'www.google.com',
port: 80,
path: '/index.html'
};

http.get(options, function(res) {
console.log("Got response: " + res.statusCode);
}).on('error', function(e) {
console.log("Got error: " + e.message);
});

还有其他选项吗?

预期输出:

Array1 = ["keyword1","keyword2","keyword3"];
Array2 = ["keyword1","keyword2","keyword3"];
Array3 = ["keyword1","keyword2","keyword3"];

Array1、Array2和Array3分别代表Site1、Site2和Site3。


尝试使用 cheerio 模块。https://github.com/cheeriojs/cheerio - Yalamber
1个回答

1

注意:该请求已被弃用。 - User123

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接