firefox cache & Python

S

subeen

Hi,

I have got into an interesting problem. Today I found that if I type
"about:cache?device=disk" (without the quotes) in the address bar of
firefox, it displays disk cache information. Now I am thinking to
write a Python program that will read this cache info. My initial idea
is to somehow save the page in a file and parse it. But how to save
the page without human intervention (pressing ctrl+s) :) ?

Hope I could make it clear what I am trying to do...

Any clue?

regards,
Subeen.
http://love-python.blogspot.com/
 
G

Gabriel Genellina

I have got into an interesting problem. Today I found that if I type
"about:cache?device=disk" (without the quotes) in the address bar of
firefox, it displays disk cache information. Now I am thinking to
write a Python program that will read this cache info. My initial idea
is to somehow save the page in a file and parse it. But how to save
the page without human intervention (pressing ctrl+s) :) ?

Search for "firefox automation"
 
M

mmayes

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/

Search for "firefox automation"

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top