I wrote a script like this to play around. Unfortunately I lost it accidentally.
As pointed in another comments, the javascript for Safari Online is pretty obfuscated and the communications to the server are "encrypted". Breaking this system seems a lot of work. However, by running your script directly in the browser, you can work around this protection very easily.
Greasemonkey, a useful Firefox extension, lets you do just that.
Here are the basics, if anyone has the patience to rewrite it:
-it is a Greasemonkey script. That means it is javascript which runs in the browser, for each page of a selected domain.
-the script would add a "save" button to the TOC page on Safari Online.
-when you click the "save" button, the script goes into saving mode and starts turning pages
-the script detects when a page is loaded by polling the status of the "loading" spinner icon or some other event (I don't remember for sure)
-for each page loaded while in saving mode, the script finds the proper DOM elements for the content (not the navbar) and cleanses the elements (href, img tags) and grabs the HTML (innerHTML)
-the HTML for each page is saved to an HTTP server to a simple service (which needs to be written for this purpose). This service saves the HTML to files.
-All the files are written to a folder (bookID) on the server and can be copied for later use.
-My toy script did not save images.
As someone mentioned, using such a script is probably against the EULA. Also, it appears that Safari Online has some defense mechanism whereas you get logged out if you make too many requests in too short an amount of time.
Last edited by dumky; 01-09-2008 at 03:06 PM.
|