This doesn’t convert encodings of give items, so convert them before call
this method if you want to send data as other than original encoding or
mixed encoding data. (strings which is encoded in HTML5 ASCII incompatible
encoding is converted to UTF-8)

This doesn’t treat files. When you send a file, use multipart/form-data.

require 'uri'
# extract first URI from html_string
html_string.slice(URI.regexp)
# remove ftp URIs
html_string.sub(URI.regexp(['ftp'])
# You should not rely on the number of parentheses
html_string.scan(URI.regexp) do |*matches|
p $&
end