るりまサーチ

最速Rubyリファレンスマニュアル検索!
236件ヒット [1-100件を表示] (0.082秒)
トップページ > クエリ:-[x] > クエリ:HTTP[x] > クエリ:open-uri[x]

別のキーワード

  1. _builtin -
  2. open-uri open
  3. irb/input-method new
  4. irb/input-method gets
  5. matrix -

検索結果

<< 1 2 3 > >>

open-uri (44214.0)

http/ftp に簡単にアクセスするためのクラスです。 Kernel.#open を再定義します。

...http/ftp に簡単にアクセスするためのクラスです。
Kernel.#open を再定義します。

=== 使用例

http
/ftp の URL を、普通のファイルのように開けます。

require 'open-uri'
open("http://www.ruby-lang.org/") {|f|
f.each_line {|line| p line}
}

開い...
...使えます。

require 'open-uri'
open("http://www.ruby-lang.org/en") {|f|
f.each_line {|line| p line}
p f.base_uri # <URI::HTTP:0x40e6ef2 URL:http://www.ruby-lang.org/en/>
p f.content_type # "text/html"
p f.charset # "iso-8859-1"
p f.content_encoding #...
...フィールドを指定できます。

require 'open-uri'
open("http://www.ruby-lang.org/en/",
"User-Agent" => "Ruby/#{RUBY_VERSION}",
"From" => "foo@bar.invalid",
"Referer" => "http://www.ruby-lang.org/") {|f|
...
}

http
_proxy, ftp_proxy, no_proxy などの環境変数は...
...http/ftp に簡単にアクセスするためのクラスです。

=== 使用例

http
/ftp の URL を、普通のファイルのように開けます。

require 'open-uri'
URI.open("http://www.ruby-lang.org/") {|f|
f.each_line {|line| p line}
}

開いたファイルオブジェクト...
...えます。

require 'open-uri'
URI.open("http://www.ruby-lang.org/en") {|f|
f.each_line {|line| p line}
p f.base_uri # <URI::HTTP:0x40e6ef2 URL:http://www.ruby-lang.org/en/>
p f.content_type # "text/html"
p f.charset # "iso-8859-1"
p f.content_encoding...
...ィールドを指定できます。

require 'open-uri'
URI.open("http://www.ruby-lang.org/en/",
"User-Agent" => "Ruby/#{RUBY_VERSION}",
"From" => "foo@bar.invalid",
"Referer" => "http://www.ruby-lang.org/") {|f|
...
}

http
_proxy, ftp_proxy, no_proxy などの環境変数は...

OpenURI.open_uri(name, mode = &#39;r&#39;, perm = nil, options = {}) -> StringIO (8298.0)

URI である文字列 name のリソースを取得して StringIO オブジェクト として返します。

...クの終了時に StringIO は close されます。nil を返します。

require 'open-uri'
sio = OpenURI.open_uri('http://www.example.com')
p sio.last_modified
puts sio.read

OpenURI.open_uri('http://www.example.com'){|sio| sio.read }

options には Hash を与えます。理解す...
...るハッシュの
キーは以下のシンボル、
* :proxy
* :progress_proc
* :content_length_proc
* :http_basic_authentication
* :proxy_http_basic_authentication
* :read_timeout
* :ssl_ca_cert
* :ssl_verify_mode
* :ftp_active_mode
* :redirect
です。
「:content_length_proc」と「:...
...
利用されることを想定しています。

require 'open-uri'
sio = OpenURI.open_uri('http://www.example.com',
{ :proxy => 'http://proxy.example.com:8000/',
:http_basic_authentication => [username, password] })

: :proxy
プロク...

OpenURI.open_uri(name, mode = &#39;r&#39;, perm = nil, options = {}) {|sio| ... } -> nil (8298.0)

URI である文字列 name のリソースを取得して StringIO オブジェクト として返します。

...クの終了時に StringIO は close されます。nil を返します。

require 'open-uri'
sio = OpenURI.open_uri('http://www.example.com')
p sio.last_modified
puts sio.read

OpenURI.open_uri('http://www.example.com'){|sio| sio.read }

options には Hash を与えます。理解す...
...るハッシュの
キーは以下のシンボル、
* :proxy
* :progress_proc
* :content_length_proc
* :http_basic_authentication
* :proxy_http_basic_authentication
* :read_timeout
* :ssl_ca_cert
* :ssl_verify_mode
* :ftp_active_mode
* :redirect
です。
「:content_length_proc」と「:...
...
利用されることを想定しています。

require 'open-uri'
sio = OpenURI.open_uri('http://www.example.com',
{ :proxy => 'http://proxy.example.com:8000/',
:http_basic_authentication => [username, password] })

: :proxy
プロク...

OpenURI::Meta#content_type -> String (8188.0)

対象となるリソースの Content-Type を文字列で返します。Content-Type ヘッダの情報が使われます。 Content-Type ヘッダがない場合は、"application/octet-stream" を返します。

...なるリソースの Content-Type を文字列で返します。Content-Type ヘッダの情報が使われます。
Content-Type ヘッダがない場合は、"application/octet-stream" を返します。

//emlist[例][ruby]{
require 'open-uri'
open('http://www.ruby-lang.org/') {|f|
p f.content...
...るリソースの Content-Type を文字列で返します。Content-Type ヘッダの情報が使われます。
Content-Type ヘッダがない場合は、"application/octet-stream" を返します。

//emlist[例][ruby]{
require 'open-uri'
URI.open('http://www.ruby-lang.org/') {|f|
p f.conten...

Kernel.#open(name, mode = &#39;r&#39;, perm = nil, options = {}) -> StringIO | Tempfile | IO (8182.0)

name が http:// や ftp:// で始まっている文字列なら URI のリソースを 取得した上で StringIO オブジェクトまたは Tempfile オブジェクトとして返します。 返されるオブジェクトは OpenURI::Meta モジュールで extend されています。

...name が http:// や ftp:// で始まっている文字列なら URI のリソースを
取得した上で StringIO オブジェクトまたは Tempfile オブジェクトとして返します。
返されるオブジェクトは OpenURI::Meta モジュールで extend されています。

name...
...a モジュールで extend されています。

Ruby2.7以降、open-uriにより拡張されたKernel.openでURLを開くときにwarningが表示されるようになりました。

require 'open-uri'
open("http://www.ruby-lang.org/") {|f|
# ...
}
#=> warning: calling URI.open via...
...@param options ハッシュを与えます。詳しくは OpenURI.open_uri を参照してください。

@raise OpenURI::HTTPError 対象となる URI のスキームが http であり、
かつリソースの取得に失敗した時に発生します。

@raise Net::FTP...

絞り込み条件を変える

Kernel.#open(name, mode = &#39;r&#39;, perm = nil, options = {}) {|ouri| ...} -> object (8182.0)

name が http:// や ftp:// で始まっている文字列なら URI のリソースを 取得した上で StringIO オブジェクトまたは Tempfile オブジェクトとして返します。 返されるオブジェクトは OpenURI::Meta モジュールで extend されています。

...name が http:// や ftp:// で始まっている文字列なら URI のリソースを
取得した上で StringIO オブジェクトまたは Tempfile オブジェクトとして返します。
返されるオブジェクトは OpenURI::Meta モジュールで extend されています。

name...
...a モジュールで extend されています。

Ruby2.7以降、open-uriにより拡張されたKernel.openでURLを開くときにwarningが表示されるようになりました。

require 'open-uri'
open("http://www.ruby-lang.org/") {|f|
# ...
}
#=> warning: calling URI.open via...
...@param options ハッシュを与えます。詳しくは OpenURI.open_uri を参照してください。

@raise OpenURI::HTTPError 対象となる URI のスキームが http であり、
かつリソースの取得に失敗した時に発生します。

@raise Net::FTP...

OpenURI::Meta#charset -> String | nil (8176.0)

対象となるリソースの文字コードを文字列で返します。Content-Type ヘッダの文字コード情報が使われます。 文字列は小文字へと変換されています。

...対象となるリソースの文字コードを文字列で返します。Content-Type ヘッダの文字コード情報が使われます。
文字列は小文字へと変換されています。

Content-Type ヘッダがない場合は、nil を返します。ただし、ブロックが与え...
...た対象となる URI のスキームが HTTP であり、自身のタイプが text である場合は、
2616 3.7.1 で定められているとおり、文字列 "iso-8859-1" を返します。

//emlist[例][ruby]{
require 'open-uri'
open("http://www.ruby-lang.org/en") {|f|
p f.content_type #...
...=> "text/html"
p f.charset # => "iso-8859-1"
}
//}...
...対象となる URI のスキームが HTTP であり、自身のタイプが text である場合は、
2616 3.7.1 で定められているとおり、文字列 "iso-8859-1" を返します。

//emlist[例][ruby]{
require 'open-uri'
URI.open("http://www.ruby-lang.org/en") {|f|
p f.content_type...
...# => "text/html"
p f.charset # => "iso-8859-1"
}
//}...

OpenURI::Meta#charset { ... } -> String (8176.0)

対象となるリソースの文字コードを文字列で返します。Content-Type ヘッダの文字コード情報が使われます。 文字列は小文字へと変換されています。

...対象となるリソースの文字コードを文字列で返します。Content-Type ヘッダの文字コード情報が使われます。
文字列は小文字へと変換されています。

Content-Type ヘッダがない場合は、nil を返します。ただし、ブロックが与え...
...た対象となる URI のスキームが HTTP であり、自身のタイプが text である場合は、
2616 3.7.1 で定められているとおり、文字列 "iso-8859-1" を返します。

//emlist[例][ruby]{
require 'open-uri'
open("http://www.ruby-lang.org/en") {|f|
p f.content_type #...
...=> "text/html"
p f.charset # => "iso-8859-1"
}
//}...
...対象となる URI のスキームが HTTP であり、自身のタイプが text である場合は、
2616 3.7.1 で定められているとおり、文字列 "iso-8859-1" を返します。

//emlist[例][ruby]{
require 'open-uri'
URI.open("http://www.ruby-lang.org/en") {|f|
p f.content_type...
...# => "text/html"
p f.charset # => "iso-8859-1"
}
//}...

OpenURI::Meta#content_encoding -> [String] (8156.0)

対象となるリソースの Content-Encoding を文字列の配列として返します。 Content-Encoding ヘッダがない場合は、空の配列を返します。

...となるリソースの Content-Encoding を文字列の配列として返します。
Content-Encoding ヘッダがない場合は、空の配列を返します。

例:

//emlist[例][ruby]{
require 'open-uri'
open('http://example.com/f.tar.gz') {|f|
p f.content_encoding #=> ["x-gzip"]
}
//}...
...るリソースの Content-Encoding を文字列の配列として返します。
Content-Encoding ヘッダがない場合は、空の配列を返します。

例:

//emlist[例][ruby]{
require 'open-uri'
URI.open('http://example.com/f.tar.gz') {|f|
p f.content_encoding #=> ["x-gzip"]
}
//}...

Kernel.#open(name, mode = &#39;r&#39;, perm = nil, options = {}) -> StringIO | Tempfile | IO (8146.0)

name が http:// や ftp:// で始まっている文字列なら URI のリソースを 取得した上で StringIO オブジェクトまたは Tempfile オブジェクトとして返します。 返されるオブジェクトは OpenURI::Meta モジュールで extend されています。

...name が http:// や ftp:// で始まっている文字列なら URI のリソースを
取得した上で StringIO オブジェクトまたは Tempfile オブジェクトとして返します。
返されるオブジェクトは OpenURI::Meta モジュールで extend されています。

name...
...FTPError のサブクラスが発生します。詳しくは net/ftp
を参照して下さい。

例:

require 'open-uri'
sio = open('http://www.example.com') { |sio|
p sio.is_a?(OpenURI::Meta) # => true
p sio.content_type
puts sio.read
}

@see OpenURI.open_ur...

絞り込み条件を変える

Kernel.#open(name, mode = &#39;r&#39;, perm = nil, options = {}) {|ouri| ...} -> object (8146.0)

name が http:// や ftp:// で始まっている文字列なら URI のリソースを 取得した上で StringIO オブジェクトまたは Tempfile オブジェクトとして返します。 返されるオブジェクトは OpenURI::Meta モジュールで extend されています。

...name が http:// や ftp:// で始まっている文字列なら URI のリソースを
取得した上で StringIO オブジェクトまたは Tempfile オブジェクトとして返します。
返されるオブジェクトは OpenURI::Meta モジュールで extend されています。

name...
...FTPError のサブクラスが発生します。詳しくは net/ftp
を参照して下さい。

例:

require 'open-uri'
sio = open('http://www.example.com') { |sio|
p sio.is_a?(OpenURI::Meta) # => true
p sio.content_type
puts sio.read
}

@see OpenURI.open_ur...

OpenURI::Meta#base_uri -> URI (8142.0)

リソースの実際の URI を URI オブジェクトとして返します。 リダイレクトされた場合は、リダイレクトされた後のデータが存在する URI を返します。

...します。
リダイレクトされた場合は、リダイレクトされた後のデータが存在する URI を返します。

//emlist[例][ruby]{
require 'open-uri'
open('http://www.ruby-lang.org/') {|f|
p f.base_uri
#=> #<URI::HTTP:0xb7043aa0 URL:http://www.ruby-lang.org/en/>
}
//}...
...ます。
リダイレクトされた場合は、リダイレクトされた後のデータが存在する URI を返します。

//emlist[例][ruby]{
require 'open-uri'
URL.open('http://www.ruby-lang.org/') {|f|
p f.base_uri
#=> #<URI::HTTP:0xb7043aa0 URL:http://www.ruby-lang.org/en/>
}
//}...
<< 1 2 3 > >>