# MozEmbed Archiving

**URL:** <https://www.ruby-forum.com/t/mozembed-archiving/118098>\
**Category:** Ruby-Gnome 2\
**Created:** [October 23, 2007, 9:20pm UTC](https://www.ruby-forum.com/t/mozembed-archiving/118098 "2007-10-23T21:20:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![redroofgreentree](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b9bd4f/32.png) [@redroofgreentree](https://www.ruby-forum.com/u/redroofgreentree)\
**Post date:** [October 23, 2007, 9:20pm UTC](https://www.ruby-forum.com/t/mozembed-archiving/118098/1 "2007-10-23T21:20:21Z")

</div>

Hi all,

I want to write a webbrowser that archives everything as I view it.  
(I.e.  
whenever it finishes loading a page, I wnat ti to do a “save everything  
as  
html” in a directory named $date-$time-$second-…

So anyway, I’m looking at the Ruby MozEmbed functions, and I see stuff  
like append\_data and render\_data … but I see no way to get the data  
back  
(I want the actual HTML, not just a screen shot.)

How can I do this? If there an easy way to intercept everything at the  
open\_stream level and copy all the data then? Is there some trick with  
MozEmbed that allows me to grab the html file that it is rendering?

Thanks!

---

<div class="post-metadata">

**Author:** ![redroofgreentree](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b9bd4f/32.png) [@redroofgreentree](https://www.ruby-forum.com/u/redroofgreentree)\
**Post date:** [October 23, 2007, 10:06pm UTC](https://www.ruby-forum.com/t/mozembed-archiving/118098/2 "2007-10-23T22:06:46Z")

</div>

The Gtkmozembed widget does not provide this level of functionality.  
However, I have devised a cunning way of building a bridge between Ruby  
and  
the Mozilla Javascript engine.

Basically the nuts and bolts of it are a parser that transforms  
Javascript  
source code into a one-liner which I then ask Mozilla to load using the  
javascript: protocol handler. I then get input back by marshaling return  
data through a JSON handler and assigning it to document.title - which I  
can  
then pick back up on the ruby side by using the Gtkmozembed title  
callback.

I use it to get the dimensions of a rendered page and then manipulate  
the  
scrollbars such that I can stitch together a full-page screenshot image.  
It  
works beautifully. I was also thinking about extending it into a full  
blown  
testing framework… not convinced this could be entirely useful yet.

Concerning your problem: using the method I have described I can  
retrieve  
the html source from the DOM - either  
document.documentElement.innerHTML, or  
a representation of the “real” DOM by calling xml.serializeToString(  
document.documentElement).

So, you could certainly retrieve the source and get a list of all of the  
page assets but you’d have to retrieve them again separately from your  
Ruby  
app… or perhaps dig them out of the Mozilla disk cache.

If you’d like a copy of my source then let me know and I’ll try and find  
some time to clean it up.

Cheers,

Andy.
