Re Dumping currently loaded Firefox URLs
bryce posted his Perl version of Dumping currently loaded Firefox URLs.
I decided perl is unreadable
and the file is json any way. So with the python-json package You can get some pretty readable code so I wrote a pretty simple Python version ff-pages.
Usage:
python ff-pages.py /path/to/location/sessionstore.js
I am starting off with python so all comments are welcome.
Update 02/06/2009:
python-json isn’t needed.
Seems to only work with firefox3.5
Perl is not unreadable, you’re just incompetent and never bothered to look properly.
thanks for this! had to tweak it slightly to cope with page titles containing unicode characters and ‘Untitled’ tabs, here’s the patch:
— old/ff-pages.py 2009-07-02 11:46:23.000000000 +0100
+++ new/ff-pages.py 2009-07-02 12:57:57.546325791 +0100
@@ -8,5 +8,6 @@
print ‘Window %s’% (i+1)
for tabs in window['tabs']:
entry = tabs['entries']
- if entry[len(entry)-1].has_key(’title’) and entry[len(entry)-1].has_key(’url’):
- print ‘\tTitle: %s Url %s’% (entry[len(entry)-1]['title'], entry[len(entry)-1]['url'])
+ if len(entry) > 0 and entry[len(entry)-1].has_key(’title’) and entry[len(entry)-1].has_key(’url’):
+ s = ‘\tTitle: %s Url %s’ % (entry[len(entry)-1]['title'], entry[len(entry)-1]['url'])
+ print unicode(s).encode(’utf8′)
hmm, looks like your blog dropped the formatting
http://paste.ubuntu.com/208082/
That might have come off as a bit harsh, however comparing your python version with the original Perl implementation, I have to say that the Perl version is a lot more robust and readable.
Even if you don’t like parsing JSON with regular expressions, it would have been a simple fix to “use JSON;”. That is however an implementation detail and I don’t see how that would imply that Perl is unreadable.
@szbalint: That comment “perl is unreadble” should have been qualified as a personal joke we have in #ubuntu-begginers on freenode with ibuclaw & sdennie.
@Dom: Thanks for your patch.
@drubin: Ah I see. I’ve just seen your post in the Planet Ubuntu aggregator and I assumed you were serious
[...] perl and python solutions presented for dumping Firefox current session URLs are not very accurate if you navigate [...]