I was trying to play with open-uri as shown on Whytheluckystiff’s
What’s Shiny and new in Ruby 1.8 article:
require 'open-uri’
require ‘yaml’
open( “http://www.whytheluckystiff.net/why.yml” ) do |f|
feed = YAML::load( f )
end
But I’m behind a firewall and need to use a proxy to get out. Any way
to use proxies with open-uri?
Phil
Phil:
you can try setting your proxy via Env variable.
export HTTP_PROXY=your.proxy.goes.here
I’m also behind a firewall, I tried it, the proxy was taken from the env var but I got the following error:
usr/local/bin/lib/ruby/1.8/open-uri.rb:143:in open_loop': undefined method
proxy_open’ for #<URI::Generic:0x200c61c0 URL:http-myproxy.com> (NoMethodError)
from /usr/local/bin/lib/ruby/1.8/open-uri.rb:105:in open_uri' from /usr/local/bin/lib/ruby/1.8/open-uri.rb:74:in
open’
from 2.rb:4
p “?”
-Ronnie.
Phil Tomson wrote:
···
I was trying to play with open-uri as shown on Whytheluckystiff’s
What’s Shiny and new in Ruby 1.8 article:
require ‘open-uri’
require ‘yaml’
open( “http://www.whytheluckystiff.net/why.yml” ) do |f|
feed = YAML::load( f )
end
But I’m behind a firewall and need to use a proxy to get out. Any way
to use proxies with open-uri?
Phil
intc_ctor@yahoo.com (Phil Tomson) wrote in message news:c68ca8f2.0401300938.22c699b9@posting.google.com…
I was trying to play with open-uri as shown on Whytheluckystiff’s
What’s Shiny and new in Ruby 1.8 article:
require ‘open-uri’
require ‘yaml’
open( “http://www.whytheluckystiff.net/why.yml” ) do |f|
feed = YAML::load( f )
end
But I’m behind a firewall and need to use a proxy to get out. Any way
to use proxies with open-uri?
Found the recipe, here it is if you need it:
open(“http://www.ruby-lang.org”,:proxy=>“http://your.proxy.here:8080”) do |f|
f.each_line {|line| p line }
end
Phil