[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

firefox cache & Python

subeen

2/19/2008 7:45:00 PM

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.blo...
3 Answers

Gabriel Genellina

2/19/2008 9:21:00 PM

0

En Tue, 19 Feb 2008 17:44:57 -0200, subeen <tamim.shahriar@gmail.com>
escribió:

> 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"

--
Gabriel Genellina

subeen

2/20/2008 9:41:00 AM

0

Searching for FF automation but still no luck.

Any other idea on how to locate the cache directory and then read the
directory ?

regards,
Subeen
http://love-python.blo...

On Feb 20, 3:20 am, "Gabriel Genellina" <gagsl-...@yahoo.com.ar>
wrote:
>
> Search for "firefox automation"
>
> --
> Gabriel Genellina

mmayes

2/20/2008 11:35:00 PM

0

On Feb 20, 3:40 am, subeen <tamim.shahr...@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.blo...
>
> On Feb 20, 3:20 am, "Gabriel Genellina" <gagsl-...@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!