Ho uno script che scarica una pagina dal web e la salva in un file:
Il problema è che non me lo salva proprio bene... (come ad es. fa mozilla)codice:conn = httplib.HTTPConnection("www.unsito.eu") conn.request("GET", "/index.html") resp = conn.getresponse() if resp.status == 200: html = resp.read() try: f = open("file.html", "w") f.write(html) f.close() except: print "/!\\ File NOT written. /!\\" else: print "/!\\ Error (" + str(resp.status) + ") /!\\" print
Salvato da mozilla:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<META NAME='Title'....
Salvato dallo script:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<META NAME='Title'....
Come mai quegli spazi in piu'? come posso eliminarli? grazie

Rispondi quotando