From dejan1 at gmail.com Tue Sep 1 19:37:47 2009 From: dejan1 at gmail.com (Dejan Tolj) Date: Tue, 1 Sep 2009 19:37:47 -0400 Subject: [Mechanize-users] field_with value not being set Message-ID: Hi, I have an issue with mechanize when I try to set a value of a textbox with a variable. I have tried the following and none of them works: my_val=5 ... search_form.field_with(:name => "q").value = my_val search_form.field_with(:name => "q").value = my_val.to_s search_form.field_with(:name => "q").value = "#{my_val}" From dejan1 at gmail.com Tue Sep 1 23:25:23 2009 From: dejan1 at gmail.com (Dejan Tolj) Date: Tue, 1 Sep 2009 23:25:23 -0400 Subject: [Mechanize-users] field_with value not being set In-Reply-To: References: Message-ID: Turns out that I was able to do this: m=my_val.to_i search_form.field_with(:name => "q").value = m On Tue, Sep 1, 2009 at 7:37 PM, Dejan Tolj wrote: > Hi, > > I have an issue with mechanize when I try to set a value of a textbox > with a variable. > I have tried the following and none of them works: > > my_val=5 > ... > search_form.field_with(:name => "q").value = my_val > search_form.field_with(:name => "q").value = my_val.to_s > search_form.field_with(:name => "q").value = "#{my_val}" > From astarr at wiredquote.com Fri Sep 4 11:24:44 2009 From: astarr at wiredquote.com (Aaron Starr) Date: Fri, 4 Sep 2009 08:24:44 -0700 Subject: [Mechanize-users] Mechanize/Nokogiri Thread Safe? Message-ID: <669cc1ca0909040824sd8c19c2q420e6bcc5acb1d60@mail.gmail.com> This question is probably specifically for Aaron Patterson, but if anyone else has experience with it, I'd love the info. I have a long-running process that takes incoming requests, does some mechanize nonsense, and returns a result. I'd like to spin off a thread for each request, so the same process could handle several simultaneous requests and thereby conserve some resources on the server. So, is Mechanize thread-safe? Is Nokogiri? Aaron -------------- next part -------------- An HTML attachment was scrubbed... URL: From aaron.patterson at gmail.com Fri Sep 4 11:29:52 2009 From: aaron.patterson at gmail.com (Aaron Patterson) Date: Fri, 4 Sep 2009 08:29:52 -0700 Subject: [Mechanize-users] Mechanize/Nokogiri Thread Safe? In-Reply-To: <669cc1ca0909040824sd8c19c2q420e6bcc5acb1d60@mail.gmail.com> References: <669cc1ca0909040824sd8c19c2q420e6bcc5acb1d60@mail.gmail.com> Message-ID: <6959e1680909040829t782e0722rd065315f41a07c64@mail.gmail.com> On Fri, Sep 4, 2009 at 8:24 AM, Aaron Starr wrote: > > This question is probably specifically for Aaron Patterson, but if anyone > else has experience with it, I'd love the info. > I have a long-running process that takes incoming requests, does some > mechanize nonsense, and returns a result. > I'd like to spin off a thread for each request, so the same process could > handle several simultaneous requests and thereby conserve some resources on > the server. > So, is Mechanize thread-safe? Is Nokogiri? Nokogiri is thread safe. For mechanize, it depends on how you use it. If you create one agent that is shared among threads, you will get unexpected results. The reason being that the history is stored on the agent, so if two threads add to the history, the referrer can end up being incorrect. One agent per thread, and you should be fine. -- Aaron Patterson http://tenderlovemaking.com/ From astarr at wiredquote.com Fri Sep 4 11:57:26 2009 From: astarr at wiredquote.com (Aaron Starr) Date: Fri, 4 Sep 2009 08:57:26 -0700 Subject: [Mechanize-users] Mechanize/Nokogiri Thread Safe? In-Reply-To: <6959e1680909040829t782e0722rd065315f41a07c64@mail.gmail.com> References: <669cc1ca0909040824sd8c19c2q420e6bcc5acb1d60@mail.gmail.com> <6959e1680909040829t782e0722rd065315f41a07c64@mail.gmail.com> Message-ID: <669cc1ca0909040857r5daee26anedbdd64ba861493f@mail.gmail.com> Ok, thanks, Aaron. Nokogiri is thread safe. For mechanize [...] One agent per thread, and you > should be fine. > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From greg.hauptmann.ruby at gmail.com Sat Sep 5 01:47:45 2009 From: greg.hauptmann.ruby at gmail.com (Greg Hauptmann) Date: Sat, 5 Sep 2009 15:47:45 +1000 Subject: [Mechanize-users] Why won't this Ruby/Mechanize HTTP POST work? (the Bank's web server gives Session Timeout response) In-Reply-To: References: <6959e1680908291016m452d5046l6e83838fdc8cdc02@mail.gmail.com> <669cc1ca0908291333h6561c149v6da66233a4e6b274@mail.gmail.com> Message-ID: 2009/8/31 Greg Hauptmann : > update - Interestingly enough the code starting working and not > throwing the error today. ?It seems to be related to how I was running > it Netbeans, as if when I did have a problem and it didn't work. > Restarting netbeans seemed to have cleared whatever the Netbeans / > Mechanize cache that existed I'm guessing....? > BTW - For future reference, thought I should point out I solved the issue. There was a hint in the previous code I'd posted: # work around 2 - the relative URI in the bank form's action does not seem to get handled, so add the front part on continue_form.action = "https://banking2.anz.com/IBAU/" + continue_form.action The work around for the mechanize issue not getting the URL correct, I had it as "banking2", however in fact what was happening is the site must be using round robin, and sometimes this would work, but other times it would be a different URL like "banking1". Fixed this up and things worked fine then, i.e. not intermittent issues. doh! From miha.ploha at gmail.com Sat Sep 5 16:16:31 2009 From: miha.ploha at gmail.com (mihael) Date: Sat, 5 Sep 2009 22:16:31 +0200 Subject: [Mechanize-users] getting an url encoded uri Message-ID: <10D9FBEC-10E3-4967-A402-BC4C9364AAF1@gmail.com> Hello, I am assembling my first cool algorithms with mechanize and I came across this weird situation. I am trying to get this uri "http://www.relax.si/kratke po?itnice.aspx" like this (with url encoded uri): agent.get("http://relax.si/kratke%20po%u010Ditnice.aspx") and in return I get: WWW::Mechanize::ResponseCodeError: 400 => Net::HTTPBadRequest from /Library/Ruby/Gems/1.8/gems/mechanize-0.9.3/lib/www/mechanize.rb: 238:in `get' The same url encoded uri works ok in browser. How does mechanize handle url encoded uri? How can I make this work? Thanks very much, Mihael From rowanu at gmail.com Thu Sep 17 05:12:01 2009 From: rowanu at gmail.com (rowan udell) Date: Thu, 17 Sep 2009 19:12:01 +1000 Subject: [Mechanize-users] Mechanize (Nokogiri?) from file Message-ID: hey everyone, have been really getting in to Mechanize recently, and would like to be able to play with it off-line. i can save the contents of a fetched page using WWW::Mechanize::Page's save_as() method, and see the contents of the page in the file, but i haven't been able to get in to a Page object later on. i'd like to be able to do an agent.get(file), and then use the usual Mechanize methods (links(), forms(), etc) on it. i've tried loaded it with a file URI ("file://...", both relative and absolute), a File object, but no luck. If was able to get it in to a Nokogiri object, that might work too. Is it something to do with the way i'm serializing the object, or how i'm (trying) to load it? thanks in advance, rowan From miha.ploha at gmail.com Thu Sep 17 05:47:23 2009 From: miha.ploha at gmail.com (mihael) Date: Thu, 17 Sep 2009 11:47:23 +0200 Subject: [Mechanize-users] Mechanize (Nokogiri?) from file In-Reply-To: References: Message-ID: hey rowan, did you try loading your pages into a local instance of apache or some other http server. then you can fetch from your local web server... regards, miha On Sep 17, 2009, at 11:12 AM, rowan udell wrote: > hey everyone, > > have been really getting in to Mechanize recently, and would like to > be able to play with it off-line. > i can save the contents of a fetched page using WWW::Mechanize::Page's > save_as() method, and see the contents of the page in the file, but i > haven't been able to get in to a Page object later on. i'd like to be > able to do an agent.get(file), and then use the usual Mechanize > methods (links(), forms(), etc) on it. i've tried loaded it with a > file URI ("file://...", both relative and absolute), a File object, > but no luck. If was able to get it in to a Nokogiri object, that > might work too. > > Is it something to do with the way i'm serializing the object, or how > i'm (trying) to load it? > > > thanks in advance, > rowan > _______________________________________________ > Mechanize-users mailing list > Mechanize-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mechanize-users From aaron.patterson at gmail.com Thu Sep 17 12:11:47 2009 From: aaron.patterson at gmail.com (Aaron Patterson) Date: Thu, 17 Sep 2009 09:11:47 -0700 Subject: [Mechanize-users] Mechanize (Nokogiri?) from file In-Reply-To: References: Message-ID: <6959e1680909170911v7f5d5655s80795145c3ca12fc@mail.gmail.com> On Thu, Sep 17, 2009 at 2:12 AM, rowan udell wrote: > hey everyone, > > have been really getting in to Mechanize recently, and would like to > be able to play with it off-line. > i can save the contents of a fetched page using WWW::Mechanize::Page's > save_as() method, and see the contents of the page in the file, but i > haven't been able to get in to a Page object later on. ?i'd like to be > able to do an agent.get(file), and then use the usual Mechanize > methods (links(), forms(), etc) on it. ?i've tried loaded it with a > file URI ("file://...", both relative and absolute), a File object, > but no luck. ?If was able to get it in to a Nokogiri object, that > might work too. > > Is it something to do with the way i'm serializing the object, or how > i'm (trying) to load it? What version of mechanize are you running? file:/// URI's should work fine. For example, I have an html file sitting in /tmp, I can load it with this script: require 'rubygems' require 'mechanize' agent = WWW::Mechanize.new page = agent.get('file:///tmp/test.html') p page -- Aaron Patterson http://tenderlovemaking.com/ From crasch at gmail.com Tue Sep 22 19:55:49 2009 From: crasch at gmail.com (Christopher Rasch) Date: Tue, 22 Sep 2009 16:55:49 -0700 Subject: [Mechanize-users] How to build Nokogiri against LibXML Version 2.6.16 Message-ID: <4AB96405.6090807@gmail.com> Hi, I installed the latest versions of libxml2 2.6.16 and libxslt 1.1.12 per the instructions here: http://ripary.com/libxml2_leopoard.html After doing so, I got the following error when I tried to run a script: WARNING: Nokogiri was built against LibXML version 2.6.16, but has dynamically loaded 2.6.30 How do I tell the Nokogiri gem to build with LibXML version 2.6.30? Thanks! Chris From crasch at gmail.com Tue Sep 22 20:26:26 2009 From: crasch at gmail.com (Christopher Rasch) Date: Tue, 22 Sep 2009 17:26:26 -0700 Subject: [Mechanize-users] Handling form fields with "." in them? Message-ID: <4AB96B32.2070507@gmail.com> Hi, Upon re-installing mechanize on a new machine, I found that the API had changed, and I'm having trouble figuring out how to upgrade my script to account for the new changes. The following used to work: page = @agent.get 'http://www.example.com' login_form = page.forms.with.name("loginForm").first login_form.fields.name("mbr.loginID").value= CONFIG['example']['login'] login_form.fields.name("mbr.password").value=CONFIG['example']['password'] page = @agent.submit(login_form) return page This is what I think the new script should be: page = login_page.form_with(:name => "loginForm") do |f| f.mbr.loginID = CONFIG['example']['login'] f.mbr.password = CONFIG['example']['password'] end.submit However, I get the following error: /usr/local/lib/ruby/gems/1.8/gems/visionmedia-commander-3.2.9/lib/commander/user_interaction.rb:101:in `method_missing': undefined method `mbr' for # (NoMethodError) The . in the field name appears to be interpreted as a method indicator. What would be the best way of referencing and assigning values to the form fields name "mbr.loginID" and "mbr.password"? Thanks! Chris