[Rails] Mechanize gem. What's the price?

2011-10-11 Thread comopasta Gr
Hi,

I've been trying to fix a problem when making a https request using
Net::HTTP
No matter how I tried I was getting and EOF error.

Then I tried with Mechanize gem and it worked like a charm.

The code I use now for Mechanize is:

agent = Mechanize.new
agent.keep_alive = true

page = agent.post("https://somewhereintime.bla";, {'tagid' => 'b6',
'source' => 'email' })

The code I was using with Net::HTTP was (gives me EOF error):

url = URI.parse("https://somewhereintime.bla";)
req = Net::HTTP::Post.new(url.path)
req.set_form_data({ 'tagid' => 'b6', 'source' => 'email' })
res = Net::HTTP.new(url.host, 443).start {|http| http.request(req)}
res.use_ssl = true



So what is the price? Less code, works better. There must be a price.
I'm I using the wrong gem just to post a request?

Just wondering...

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Mechanize gem

2009-05-30 Thread Saurabh Peshkar

Hi All,

I am trying to use Mechanize gem for some url, I am submitting the form
in that url but on the following submit command I got an error message.

command: page = agent.submit(search_form)

error: Iconv::InvalidEncoding
invalid encoding ("ISO-8859-1;", "UTF-8")



Please help me out,

Thanks in advance,
Saurabh
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---