forked from apis-is/apis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
House lookup endpoint added. Still needs alot of love. Also some cleanup
- Loading branch information
1 parent
f290fdd
commit 116db2d
Showing
7 changed files
with
318 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,44 @@ | ||
//Possible endpoint: | ||
//https://www.isnic.is/is/whois/mini.php?type=all&query=apis.is | ||
exports.setup = function(){ | ||
server.get({path: '/whois', version: '1.0.0'}, slash); | ||
} | ||
|
||
slash = function(req, res, next){ | ||
|
||
var data = req.params; | ||
|
||
if(!data.url) data.url = ''; | ||
|
||
var url = 'http://www.isnic.is/is/whois/mini.php?type=all&query='+data.url; | ||
|
||
request.get({ | ||
headers: {'User-Agent': h.browser()}, | ||
url: url | ||
}, function(error, response, body){ | ||
if(error){ | ||
res.json(500,{error:"Something went wrong on the server"}); | ||
return next(); | ||
} | ||
var data = $(body), | ||
obj = { results: []}; | ||
|
||
|
||
console.log(data.find("h3").html()) | ||
console.log($("h3").html()) | ||
if(data.find("h3").length > 0){ | ||
var obj = { | ||
found: false | ||
}; | ||
res.json(200,obj) | ||
}else{ | ||
res.json({"fannst":true}) | ||
} | ||
|
||
h.logVisit('/whois', obj,false); | ||
|
||
res.end(); | ||
//res.json(200,obj) | ||
return next(); | ||
}); | ||
} |
Oops, something went wrong.