Forum: Ruby help me with Net::HTTP

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
41d423e29a5a40802aa6578654ad1102?d=identicon&s=25 travis laduke (Guest)
on 2006-02-14 09:38
(Received via mailing list)
please?
#from the api on ruby-doc.org. http://www.ruby-doc.org/stdlib/libdoc/
net/http/rdoc/classes/Net/HTTP.html

require 'net/http'
require 'uri'

     #1: Simple POST
     res = Net::HTTP.post_form(URI.parse('http://www.example.com/
search.cgi'),
                               {'q'=>'ruby', 'max'=>'50'})
     puts res.body


5: undefined method `post_form' for Net::HTTP:Class (NoMethodError)

am i missing something here? if it matters, my OS is Tiger... ruby
1.8.2 (2004-12-25) [powerpc-darwin8.2.0]

alternatively, how to you make Mechanize work from inside rails? i'm
trying to screen scrape a table from another site then load the
information back on my page.

why does time fly so fast when i'm stuck on something?

travid
5befe95e6648daec3dd5728cd36602d0?d=identicon&s=25 Robert Klemme (Guest)
on 2006-02-14 10:54
(Received via mailing list)
travis laduke wrote:
>                                {'q'=>'ruby', 'max'=>'50'})
>      puts res.body
>
>
> 5: undefined method `post_form' for Net::HTTP:Class (NoMethodError)
>
> am i missing something here? if it matters, my OS is Tiger... ruby
> 1.8.2 (2004-12-25) [powerpc-darwin8.2.0]

Works for me (cygwin, Ruby 1.8.4).  Maybe it was renamed.  Try

ruby -r net/http -e 'puts Net::HTTP.public_methods.grep(/post/i).sort'

ruby -r net/http -e 'puts Net::HTTP.public_methods.sort'

> why does time fly so fast when i'm stuck on something?

Hehe, know that - been there before.  Sometimes it helps to just have a
break.

Kind regards

    robert
04d072ab8843cfd3d1714faf3a2a0fb2?d=identicon&s=25 mathew (Guest)
on 2006-02-14 23:21
(Received via mailing list)
travis laduke wrote:
> 5: undefined method `post_form' for Net::HTTP:Class (NoMethodError)
>
> am i missing something here? if it matters, my OS is Tiger... ruby 1.8.2
> (2004-12-25) [powerpc-darwin8.2.0]

Tiger's Ruby is an old version. post_form is present in the current
version of ruby, which is what ruby-doc.org documents.


mathew
This topic is locked and can not be replied to.