firefox cache & Python
mmayes
stoptimestudio at gmail.com
Wed Feb 20 18:35:12 EST 2008
On Feb 20, 3:40 am, subeen <tamim.shahr... at gmail.com> wrote:
> Searching for FF automation but still no luck.
>
> Any other idea on how to locate the cache directory and then read the
> directory ?
>
> regards,
> Subeenhttp://love-python.blogspot.com/
>
> On Feb 20, 3:20 am, "Gabriel Genellina" <gagsl-... at yahoo.com.ar>
> wrote:
>
>
>
> > Search for "firefox automation"
>
> > --
> > Gabriel Genellina
You can generally locate Firefox's cache (v2 and up) directory by
searching for a file named '_CACHE_MAP_':
Try something like:
-- code --
import sys
import os
searchFile = '_CACHE_MAP_'
cacheFolder = None
home = "/Users/your-home-directory" # assuming *nix OS
for root, dirs, files in os.walk(home):
for x in files:
if x == searchFile:
cacheFolder = root
print cacheFolder
if cacheFolder == None: print "Cache folder not found under that
directory."
-- end code --
The main cache data as far as URLs and such are located in 3 files,
which you can dump into a list:
cacheFiles = ['_CACHE_001_', '_CACHE_002_', '_CACHE_003_']
You can then read data into a string with something like:
all_cache = ''
for f in cacheFiles:
all_cache += open(cacheFolder + '/' + f, 'rb').read() # '/' = *nix
OS dividor
The odd looking files that start with numbers are some sort of binary/
gzipped encoded files, which I'm still working on. Keep an eye on my
blog, I'll post a bunch of stuff on this soon, as I'm working on a
project for a class that deals with this stuff. Cheers!
More information about the Python-list
mailing list