Parsing URLs : URI « Network « Ruby






Parsing URLs


require 'uri'

puts URI.parse('https://www.example.com').scheme           # => "https"
puts URI.parse('http://www.example.com/').host             # => "www.example.com"
puts URI.parse('http://www.example.com:6060/').port        # => 6060
puts URI.parse('http://example.com/a/file.html').path      # => "/a/file.html"

 








Related examples in the same category

1.Split a URL
2.URI::HTTP.component
3.URI::MailTo.component
4.Create a URL with URI::HTTP.build
5.Dump a URL
6.mailto URI parse
7.URI parse
8.Extracting All the URLs from an HTML Document
9.Get only http and https based url