views:

439

answers:

1

Hey, I searched on google and read in the ruby manuals, but I couldn't find a way to use WWW::Mechanize and NET::HTTP::GET over a socks4 proxy.

I read, that WWW::Mechanize is a subclass of the UserAgent module, and that therefore the ->proxy() method would work. But the manual only talks about http, ftp and gopher proxy.

Any ideas how to support socks4? Here are the code snippets:

def get_request(url_in)
    url = URI.parse(url_in)
    req = Net::HTTP::Get.new(url.path, {"User-Agent" => $UserAgent})

    res = Net::HTTP.start(url.host, url.port) { |http|
     http.request(req)
    }


    return res.body
end
 agent   = WWW::Mechanize.new
    agent.user_agent_alias('Windows Mozilla')
    page    = agent.get("urlhere")
    post_form  = page.form('post')

Thanks for reading

+2  A: 

You probably want to look at Ruby socksify. I don't think that the HTTP client has any support for SOCKS proxies; only HTTP proxies for HTTP.

hobbs
thanks, solved now. works fine
maxedmelon