code debugging

Gabriel Genellina gagsl-py2 at
Sun Jul 26 11:19:52 CEST 2009

En Sun, 26 Jul 2009 03:33:27 -0300, golu <bhardwajjayesh7 at>  

> i want to save pages in a directory and i m using the urls to get
> filenames. The program gets stuck in the saving step.can u suggest me
> a way to save a page e.g as a file google.html

You may use str.translate to replace/remove all undesired characters:

py> import string
py> valid = string.ascii_letters+string.digits+'.'
py> invalid = ''.join(chr(x) for x in range(256) if chr(x) not in valid)
py> table = string.maketrans(invalid, '_'*len(invalid))
py> x = ''
py> x.translate(table)


Gabriel Genellina

More information about the Python-list mailing list