[Celerity-users] page cacheing
jason franklin-stokes
jasoninclass at googlemail.com
Wed Sep 9 04:45:19 EDT 2009
Hi Jari,
Brilliant - thanks - that works!!.
However - i tried to do this while using celerity, unfortunately with
not much success - as soon as i try to serialize browser.page it bombs
out with:
"org/apache/commons/lang/SerializationUtils.java:111:in `serialize':
org.apache.commons.lang.SerializationException:
java.io.NotSerializableException:
org.jruby.gen.InterfaceImpl1274989706 (NativeException)"
I totally don't understand why. have you got any ideas?
here the simplified case:
#############################
# NOT WORKING USING CELERITY
#############################
require 'rubygems'
require 'celerity'
require 'java'
include_class 'org.apache.commons.lang.SerializationUtils'
browser = Celerity::Browser.new :browser => :firefox, :log_level => :off
browser.goto("http://www.google.de")
serialized_page = SerializationUtils.serialize(browser.page) #
<---------- bombs out here
#############################
# WORKING NOT USING CELERITY
#############################
require 'rubygems'
require 'java'
require 'htmlunit-2.7-SNAPSHOT.jar'
include_class 'com.gargoylesoftware.htmlunit.WebClient'
include_class 'org.apache.commons.lang.SerializationUtils'
include_class 'com.gargoylesoftware.htmlunit.BrowserVersion';
version = BrowserVersion.new( "Netscape", "5.0 (Macintosh; en-US)",
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.14) Gecko/
20080404 Firefox/2.0.0.14", "1.2" , 5.0 )
webclient = WebClient.new(version)
page = webclient.getPage("http://www.google.de")
serialized_page = SerializationUtils.serialize(page)
File.open("serialized_page.data", "wb") { |file| file <<
serialized_page.to_a.pack("C*") }
page_from_disk = File.read("serialized_page.data") #.unpack("C*")
puts page_from_disk.inspect
On Sep 7, 2009, at 8:22 PM, Jari Bakken wrote:
> Hello Jason,
>
> On Mon, Sep 7, 2009 at 7:08 PM, jason
> franklin-stokes<jasoninclass at googlemail.com> wrote:
>> Have you go any Ideas on how I can get the serialized data form the
>> htmlunit
>> side on to disk and back off again and back to htmlunit?
>>
>
>
> This seems to work - http://gist.github.com/182493
> _______________________________________________
> Celerity-users mailing list
> Celerity-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/celerity-users
More information about the Celerity-users
mailing list