I'm having some issues with Firefox and pysqlite2. Both versions are running Python 2.7 from what I can tell.
If I run this on Linux:
$ python firefox.py -d /home/<username>/Desktop/ -b Firefox -p bookmark
Traceback (most recent call last):
File "barff_0_rev3_firefox.py", line 241, in <module>
main()
File "barff_0_rev3_firefox.py", line 237, in main
bookmark = browser.get_bookmarks()
File "barff_0_rev3_firefox.py", line 154, in get_bookmarks
cursor.execute('SELECT datetime(moz_bookmarks.dateAdded/1000000, \'unixepoch\') AS \'Date Added\', moz_bookmarks.title AS \'Title\', moz_places.url AS \'URL\', moz_places.visit_count AS \'Count\' FROM moz_bookmarks, moz_places WHERE moz_places.id = moz_bookmarks.fk ORDER BY moz_bookmarks.dateAdded ASC')
If I run it on Windows:
>firefox.py -b Firefox -d C:\Users\<username>\Desktop -p bookmark
2012-11-22 20:58:53 | Getting Started | http://www.mozilla.com/en-US/firefox/central/ | 0
2012-11-22 20:58:53 | Help and Tutorials | http://www.mozilla.com/en-US/firefox/help/ | 0
2012-11-22 20:58:53 | Customize Firefox | http://www.mozilla.com/en-US/firefox/customize/ | 0
2012-11-22 20:58:53 | Get Involved | http://www.mozilla.com/en-US/firefox/community/ | 0
Here is the code doing the parsing:
# Firefox browser class
class Firefox(browserCommon):
def __init__(self, profile_directory):
browserCommon.__init__(self, profile_directory)
def get_bookmarks(self):
res = []
(conn, cursor) = self.get_conn_cursor('places.sqlite')
cursor.execute('SELECT datetime(moz_bookmarks.dateAdded/1000000, \'unixepoch\') AS \'Date Added\', moz_bookmarks.title AS \'Title\', moz_places.url AS \'URL\', moz_places.visit_count AS \'Count\' FROM moz_bookmarks, moz_places WHERE moz_places.id = moz_bookmarks.fk ORDER BY moz_bookmarks.dateAdded ASC')
for (dateAdded, title, url, visit_count) in cursor.fetchall():
res.append(bookmarksEntry(dateAdded, title, url, visit_count))
return res
Program Imports:
import datetime, time
import sys, getopt, os
from cStringIO import StringIO
from pysqlite2 import dbapi2 as sqlite
from django.utils.encoding import smart_str