1

是否有任何 Ruby gem 用于获取 web 主机详细信息,如 os 、 server 、 dns 服务器和服务器端技术等,

4

1 回答 1

0

HTTParty可以向您显示应包含此类信息的响应标头(如果已公开提供)。

require 'httparty'
HTTParty.get('http://www.google.com').headers                                                 
#=> {
#  "date"=>["Wed, 13 Nov 2013 14:30:22 GMT"],
#  "expires"=>["-1"],
#  "cache-control"=>["private, max-age=0"],
#  "content-type"=>["text/html; charset=ISO-8859-1"],
#  "set-cookie"=>["PREF=ID=e77b1a34a6c800b7:U=d34bac1ee0ebd206:FF=0:TM=1384353022:LM=1384353022:S=vJvIFTH7In_YgQ6s; expires=Fri, 13-Nov-2015 14:30:22 GMT; path=/; domain=.google.co.uk"],
#  "server"=>["gws"],
#  "x-xss-protection"=>["1; mode=block"],
#  "x-frame-options"=>["SAMEORIGIN"],
#  "connection"=>["close"]
#}

HTTParty.get('http://www.google.com').headers['server']                                              
#=> "gws"
于 2013-11-13T14:31:19.167 回答