文章会有【原创】或者【转载】标示,部分来自Google Baidu的学习结果 {Java/PHP/Python/Ruby/Go}

Ruby 取得域名的Host【转载】  


比如说我用PHP就是parse_url这个函数可以
Ruby 我找了个手册
以下内容:转载自:http://www.kuqin.com/rubycndocument/man/addlib/URI.html
require 'uri' p URI.split("http://www.ruby-lang.org/") # => ["http", nil, "www.ruby-lang.org", nil, nil, "/", nil, nil, nil]

require 'uri' p uri = URI.parse("http://www.ruby-lang.org/") # => #<URI::HTTP:0x201002a6 URL:http://www.ruby-lang.org/> p uri.scheme # => "http" p uri.host # => "www.ruby-lang.org" p uri.port # => 80 p uri.path # => "/"

require 'uri' p URI.join('http://www.ruby-lang.org/', '/ja/man-1.6/') => #<URI::HTTP:0x2010017a URL:http://www.ruby-lang.org/ja/man-1.6/>
。。。