Hi. Recently I started rebuilding my old Mechanize script, which I used to automatically log in to a certain site and retrieve files from it. Old version worked great, however, when I did the update it started complaining. Here''s the log of the error: /Users/lukastolyarov/.gem/ruby/1.8/gems/mechanize-1.0.0/lib/mechanize/form/field.rb:30:in `<=>'': undefined method `<=>'' for <input type="hidden" name="next" value="/blog/">:Nokogiri::XML::Element (NoMethodError) from /Users/lukastolyarov/.gem/ruby/1.8/gems/mechanize-1.0.0/lib/mechanize/form.rb:171:in `sort'' from /Users/lukastolyarov/.gem/ruby/1.8/gems/mechanize-1.0.0/lib/mechanize/form.rb:171:in `build_query'' from /Users/lukastolyarov/.gem/ruby/1.8/gems/mechanize-1.0.0/lib/mechanize/form.rb:221:in `request_data'' from /Users/lukastolyarov/.gem/ruby/1.8/gems/mechanize-1.0.0/lib/mechanize.rb:452:in `post_form'' from /Users/lukastolyarov/.gem/ruby/1.8/gems/mechanize-1.0.0/lib/mechanize.rb:370:in `submit'' from downloader.rb:16:in `downloader'' from downloader.rb:38 Basically, what I''m doing is this: require ''rubygems'' require ''mechanize'' agent = Mechanize.new # create agent bject page = agent.get(''www.mysite.com";) #authenticate form = page.forms.first form.username = ''username'' form.password = ''password'' #submit form page = agent.submit form I think what''s causing the error is a hidden field that the form has which looks like this: <input type="hidden" name="next" value="/blog/"> do you guys know how I can circumvent this issue? Thanks! Luka
I think you have to update nokogiri, too. On Thu, Jun 3, 2010 at 10:20 AM, Luka Stolyarov <lukich at gmail.com> wrote:> Hi. Recently I started rebuilding my old Mechanize script, which I > used to automatically log in to a certain site and retrieve files from > it. Old version worked great, however, when I did the update it > started complaining. Here''s the log of the error: > > > /Users/lukastolyarov/.gem/ruby/1.8/gems/mechanize-1.0.0/lib/mechanize/form/field.rb:30:in > `<=>'': undefined method `<=>'' for <input type="hidden" name="next" > value="/blog/">:Nokogiri::XML::Element (NoMethodError) > from > /Users/lukastolyarov/.gem/ruby/1.8/gems/mechanize-1.0.0/lib/mechanize/form.rb:171:in > `sort'' > from > /Users/lukastolyarov/.gem/ruby/1.8/gems/mechanize-1.0.0/lib/mechanize/form.rb:171:in > `build_query'' > from > /Users/lukastolyarov/.gem/ruby/1.8/gems/mechanize-1.0.0/lib/mechanize/form.rb:221:in > `request_data'' > from > /Users/lukastolyarov/.gem/ruby/1.8/gems/mechanize-1.0.0/lib/mechanize.rb:452:in > `post_form'' > from > /Users/lukastolyarov/.gem/ruby/1.8/gems/mechanize-1.0.0/lib/mechanize.rb:370:in > `submit'' > from downloader.rb:16:in `downloader'' > from downloader.rb:38 > > > Basically, what I''m doing is this: > > require ''rubygems'' > require ''mechanize'' > > agent = Mechanize.new > > # create agent bject > page = agent.get(''www.mysite.com";) > > #authenticate > form = page.forms.first > form.username = ''username'' > form.password = ''password'' > > #submit form > page = agent.submit form > > I think what''s causing the error is a hidden field that the form has > which looks like this: > > <input type="hidden" name="next" value="/blog/"> > > do you guys know how I can circumvent this issue? > > Thanks! > Luka > _______________________________________________ > Mechanize-users mailing list > Mechanize-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mechanize-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/mechanize-users/attachments/20100603/d6498fd6/attachment.html>
That was painless. Thanks! On Thu, Jun 3, 2010 at 4:13 PM, Aaron Starr <astarr at wiredquote.com> wrote:> > I think you have to update nokogiri, too. > > On Thu, Jun 3, 2010 at 10:20 AM, Luka Stolyarov <lukich at gmail.com> wrote: >> >> Hi. ?Recently I started rebuilding my old Mechanize script, which I >> used to automatically log in to a certain site and retrieve files from >> it. ?Old version worked great, however, when I did the update it >> started complaining. ?Here''s the log of the error: >> >> >> /Users/lukastolyarov/.gem/ruby/1.8/gems/mechanize-1.0.0/lib/mechanize/form/field.rb:30:in >> `<=>'': undefined method `<=>'' for <input type="hidden" name="next" >> value="/blog/">:Nokogiri::XML::Element (NoMethodError) >> ? ? ? ?from >> /Users/lukastolyarov/.gem/ruby/1.8/gems/mechanize-1.0.0/lib/mechanize/form.rb:171:in >> `sort'' >> ? ? ? ?from >> /Users/lukastolyarov/.gem/ruby/1.8/gems/mechanize-1.0.0/lib/mechanize/form.rb:171:in >> `build_query'' >> ? ? ? ?from >> /Users/lukastolyarov/.gem/ruby/1.8/gems/mechanize-1.0.0/lib/mechanize/form.rb:221:in >> `request_data'' >> ? ? ? ?from >> /Users/lukastolyarov/.gem/ruby/1.8/gems/mechanize-1.0.0/lib/mechanize.rb:452:in >> `post_form'' >> ? ? ? ?from >> /Users/lukastolyarov/.gem/ruby/1.8/gems/mechanize-1.0.0/lib/mechanize.rb:370:in >> `submit'' >> ? ? ? ?from downloader.rb:16:in `downloader'' >> ? ? ? ?from downloader.rb:38 >> >> >> Basically, what I''m doing is this: >> >> require ''rubygems'' >> require ''mechanize'' >> >> ?agent = Mechanize.new >> >> ?# create agent bject >> ?page = agent.get(''www.mysite.com";) >> >> ?#authenticate >> ?form = page.forms.first >> ?form.username = ''username'' >> ?form.password = ''password'' >> >> ?#submit form >> ?page = agent.submit form >> >> I think what''s causing the error is a hidden field that the form has >> which looks like this: >> >> ?<input type="hidden" name="next" value="/blog/"> >> >> do you guys know how I can circumvent this issue? >> >> Thanks! >> Luka >> _______________________________________________ >> Mechanize-users mailing list >> Mechanize-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/mechanize-users > > > _______________________________________________ > Mechanize-users mailing list > Mechanize-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mechanize-users >
Possibly Parallel Threads
- NoMethodError: undefined method `force_encoding' for "Conten
- submit button param is duplicated when a form is submitted a second time
- Load Error Using Mechanize Gem
- Mechanize#get vs Mechanize#fetch_page
- input form fields not in the #<WWW::Mechanize::Form array