En Sun, 26 Jul 2009 03:33:27 -0300, golu <bhardwajjaye...@gmail.com> escribió:

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 google.com 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 = 'http://docs.python.org/library/string.html'
py> x.translate(table)
'http___docs.python.org_library_string.html'

See http://docs.python.org/library/stdtypes.html#str.translate

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to