Discussion:
nsIWebBrowserPersist saveDocument() method
Nashid
2010-04-07 01:20:30 UTC
Permalink
Dear Concerned,

I am using mozilla interface nsIWebBrowserPersist (https://
developer.mozilla.org/en/XPCOM_Interface_Reference/
nsIWebBrowserPersist) with a method called saveDocument().

I have integrated this one with mozrepl. So if I give repl.save() it
is saving the page.

But the problem is it saves the html without any image. But as per
specification it is to save the specified DOM document to file and
optionally all linked files (e.g. images, CSS, JS & subframes).

Please note that I have also given a delay loop in javascript.

Do you have any advice? Am I missing something?

Thanks
Nashid
Boris Zbarsky
2010-04-07 01:26:44 UTC
Permalink
Post by Nashid
I am using mozilla interface nsIWebBrowserPersist (https://
developer.mozilla.org/en/XPCOM_Interface_Reference/
nsIWebBrowserPersist) with a method called saveDocument().
I have integrated this one with mozrepl. So if I give repl.save() it
is saving the page.
But the problem is it saves the html without any image. But as per
specification it is to save the specified DOM document to file and
optionally all linked files (e.g. images, CSS, JS& subframes).
How are you calling saveDocument?

-Boris
Nashid
2010-04-07 14:21:36 UTC
Permalink
Post by Boris Zbarsky
Post by Nashid
I am using mozilla interface nsIWebBrowserPersist (https://
developer.mozilla.org/en/XPCOM_Interface_Reference/
nsIWebBrowserPersist) with a method called saveDocument().
I have integrated this one with mozrepl. So if I give repl.save() it
is saving the page.
But the problem is it saves the html without any image. But as per
specification it is to save the specified DOM document to file and
optionally all linked files (e.g. images, CSS, JS&  subframes).
How are you calling saveDocument?
-Boris
wbp.saveDocument(content.document, file, null,null, encodingFlags,
null);
Boris Zbarsky
2010-04-07 14:51:29 UTC
Permalink
Post by Nashid
wbp.saveDocument(content.document, file, null,null, encodingFlags,
null);
From
http://mxr.mozilla.org/mozilla-central/source/embedding/components/webbrowserpersist/public/nsIWebBrowserPersist.idl
the documentation for that third argument (your first null) is:

268 * @param aDataPath Path to directory where URIs linked
to the document
269 * are saved or nsnull if no linked URIs
should be saved.
270 * This may be a nsILocalFile object or
an nsIURI object
271 * with a file scheme.

-Boris
Nashid
2010-04-07 15:07:36 UTC
Permalink
Post by Nashid
wbp.saveDocument(content.document, file, null,null, encodingFlags,
null);
 Fromhttp://mxr.mozilla.org/mozilla-central/source/embedding/components/we...
to the document
269    *                           are saved or nsnull if no linked URIs
should be saved.
270    *                           This may be a nsILocalFile object or
an nsIURI object
271    *                           with a file scheme.
-Boris
I have changed it. Now it saves the images. Still i dont get the exact
copy like that is saved in the web page. It seems css,js are not taken
properly. Do you have any idea about this? Do I need to change the
aOutputContentType?

Or any other idea to save a page locally like a scrapper solution. How
the scrappers save everything in a correct format?

Thanks
Nashid
Nashid
2010-04-08 12:22:15 UTC
Permalink
Post by Nashid
Post by Nashid
wbp.saveDocument(content.document, file, null,null, encodingFlags,
null);
 Fromhttp://mxr.mozilla.org/mozilla-central/source/embedding/components/we...
to the document
269    *                           are saved or nsnull if no linked URIs
should be saved.
270    *                           This may be a nsILocalFile object or
an nsIURI object
271    *                           with a file scheme.
-Boris
I have changed it. Now it saves the images. Still i dont get the exact
copy like that is saved in the web page. It seems css,js are not taken
properly. Do you have any idea about this? Do I need to change the
aOutputContentType?
Or any other idea to save a page locally like a scrapper solution. How
the scrappers save everything in a correct format?
Thanks
Nashid
Even if I give Save As from the File Menu is Mozilla Firefox I cant
save the totally with "Save Page Complete" option.
Then how some scrapping solutions works
Any idea?

Thanks
Nashid

Loading...