Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    [Python] Problema salvataggio file dal web

    Ho uno script che scarica una pagina dal web e la salva in un file:

    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
    Il problema è che non me lo salva proprio bene... (come ad es. fa mozilla)

    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
    PiKey
    got excited by ubuntu edgy eft
    www.pikkio.net/blog

  2. #2

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.