MozRepl and saving HTML data

262 views
Skip to first unread message

J. Bobby Lopez

unread,
Nov 8, 2008, 3:47:27 PM11/8/08
to MozLab
Hello,

I'm new to MozRepl, and don't have a lot of background with javascript
(I'm a perl guy). I'm learning both, but I'm running into a roadblock
trying to figure out how to save an HTML page via MozRepl.

First I thought that I might be able to issue a "Save As" from
MozRepl, using "document.execCommand('SaveAs'..", however that
apparently only works in IE.

Second, I figured that I might be able to dump the HTML for the entire
document in the MozRepl console, using something like "print
document.body.innerHTML;", but I'm at a loss as to the correct syntax,
or if this is even possible.

The goal is to get Firefox to save a page to a file, or MozRepl to
dump the full HTML for the page, so that I can intercept the data with
perl Expect module.

Would anyone have any suggestions on this?


Thanks very much.

Bobby

J. Bobby Lopez

unread,
Nov 9, 2008, 9:25:02 AM11/9/08
to MozLab
Ok, I figured out that simply typing 'document.body.innerHTML' at the
prompt will dump the HTML to the console, which is awesome. Is there
any way to save this to a file using MozRepl, or would I have to do
that via my perl code?

Massimiliano Mirra

unread,
Nov 9, 2008, 3:31:11 PM11/9/08
to moz...@googlegroups.com
Hi Bobby,

you can use Mozilla's I/O objects, see:
https://developer.mozilla.org/en/Code_snippets/File_I%2F%2FO

(I guess a repl.save(data, filePath) would be nice to have for the future...)

曹文明

unread,
Apr 30, 2012, 9:36:47 PM4/30/12
to moz...@googlegroups.com
On Sunday, November 9, 2008 4:47:27 AM UTC+8, J. Bobby Lopez wrote:
I'm new to MozRepl, and don't have a lot of background with javascript
(I'm a perl guy).
as for perl users , there is WWW::Mechanize::Firefox on cpan which in turn
utilises mozrepl in its implementation . from the outside , it claims to work
just like WWW::Mechanize . personally haven't tried this yes , hope this be
somekind useful to you .

Reply all
Reply to author
Forward
0 new messages