检查网站是否可联系

我想检查一个特定的网站是否在线。 网站的名称来自一个input字段,并通过邮件发送。

有一个用于ping主机的NPM模块,但是这对我没有太大的帮助。 我需要一个用params来检查URL的解决scheme,例如: hostname.com/category

我会感激的build议。

只是做一个HTTP请求。

 var http = require('http'); http.get('http://example.com/category', function (res) { // If you get here, you have a response. // If you want, you can check the status code here to verify that it's `200` or some other `2xx`. }).on('error', function(e) { // Here, an error occurred. Check `e` for the error. });;