Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby open uri download via proxy

I don't know how to download data from URL using open-uri and active proxy.

I used this code:

    proxy = Net::HTTP::Proxy("??????????????????????")
    proxy.start('http://www.example.com') { |http|  
    puts open(strURL).read 
    }

but Ruby returned error: c:/Ruby192/lib/ruby/1.9.1/net/http.rb:644:in `initialize': A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. - connect(2) (Errno::ETIMEDOUT)

What's wrong ?( I don't want to use HTTP)(

like image 571
user1119425 Avatar asked Jan 23 '26 23:01

user1119425


1 Answers

Try this :

require 'open-uri'
p = open('http://www.example.com', 
          proxy: URI.parse("http://190.72.158.80:8080")
        )
like image 169
Isha Aggarwal Avatar answered Jan 25 '26 14:01

Isha Aggarwal