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
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
On Thu, Sep 17, 2009 at 2:12 AM, rowan udell <rowanu at gmail.com> 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/