2014-12-06 1 views
5

Ich möchte überprüfen, ob eine bestimmte Website online ist. Der Name der Website stammt aus einem Eingabefeld und wird per Post versandt.Prüfen, ob die Website erreichbar ist

Es gibt ein NPM-Modul für Ping-Hosts, aber das hilft mir nicht so viel. Ich brauche eine Lösung für die Überprüfung URLs mit Parametern, wie: hostname.com/category

Ich wäre dankbar für Anregungen.

Antwort

8

Machen Sie einfach eine HTTP-Anfrage.

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. 

});; 
+0

Danke Mann, das ist eine Lösung, die mir noch einmal hilft – pkberlin