elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Curso de javascript por TickTack


+  Foro de elhacker.net
|-+  Programación
| |-+  Scripting
| | |-+  CREANDO UN DOWNLOADER EN PYTHON
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: CREANDO UN DOWNLOADER EN PYTHON  (Leído 2,675 veces)
43H4FH44H45H4CH49H56H45H
Wiki

Desconectado Desconectado

Mensajes: 502



Ver Perfil
CREANDO UN DOWNLOADER EN PYTHON
« en: 4 Julio 2008, 05:41 am »

Buenas, buscando información acerca de como manipular text, entry, label's y otros en python me encontre con este code, en el que se muestra como hacerlo, lo dejo por si a alguien tb le sirve.

Código:
from Tkinter import *
import os
import urllib
import threading
import time

def logs(b):
    f = open('./downloads/log.txt','aw')
    f.write ("Archivo %s" % b + "descargado %s \n" % time.strftime("a Horas: %H:%M:%S en Fecha: %D"))
    f.close()


def reporthook(blocks_read, block_size, total_size):
    if not blocks_read:
        myapp.lab1["text"] = "conexión Establecida"
        return
    if total_size < 0:
        myapp.lab1["text"] = "Bloques Leidos " % blocks_read
    else:
        amount_read = blocks_read * block_size
        myapp.lab1["text"] = "Faltan: %d Kb para terminar la Descarga" %((total_size/1024) -  (amount_read/1024))
        return
   
class Hilo(threading.Thread ):
    def run ( self ):
        try:
            i = 0
            while i==0:
                c = myapp.text3.get(1.0, 2.0)
                b = c[c.rfind('/',0,len(c))+1:len(c)]
                urllib.urlretrieve("%s" % myapp.text3.get(1.0, 2.0), 'downloads/%s' % b, reporthook=reporthook)
                myapp.lab1["text"] = "ARCHIVO %s DESCARGADO" % b
                logs(b)

                myapp.text3.delete(1.0, 2.0)

                if myapp.text3.search("http://", 1.0, 1.7):
                    myapp.lab1["text"] = "CONTINUANDO DESCARGA"
                    continue;
                else:
                    myapp.lab1["text"] = "NO HAY URLS PARA DESCARGAR"
                    break;
                                     
        except:
           myapp.lab1["text"] = "ERROR VERIFIQUE conexión Y DIRECCION URL"

class Application(Frame):

   
    def limpiar(self):
        myapp.text3.delete(1.0, END)

     
    def download(self):
        if os.path.exists("downloads")==0:
            os.makedirs("downloads")

        Hilo().start()
       
    def salir(self):

        myapp.master.destroy()
        exit()


    def agregar(self):

        myapp.text3.insert(END, myapp.text3.clipboard_get()+"\n")
                     
    def createWidgets(self):

        self.lab0 = Label(self)
        self.lab0["text"] = "INTRODUCE DIRECCION A DESCARGAR"
        self.lab0["fg"]   = "white"
        self.lab0["bg"]   = "black"
        self.lab0["width"]   = 50
        self.lab0["height"]   = 3
        self.lab0.pack({"side": "top"})


        self.lab1 = Label(self)
        self.lab1["text"] = "CONTADOR DESCARGA PREPARADO"
        self.lab1["fg"]   = "white"
        self.lab1["bg"]   = "black"
        self.lab1["width"]   = 80
        self.lab1["height"]   = 3
        self.lab1.pack({"side": "top"})


        self.but1 = Button(self)
        self.but1["text"] = "AGREGAR URL DEL PORTAPAPELES"
        self.but1["fg"]   = "white"
        self.but1["bg"]   = "blue"
        self.but1["width"]   = 30
        self.but1["height"]   = 2
        self.but1["border"]   = 4
        self.but1.grid(row = 10, sticky = E, column = 2, pady = 3)
        self.but1["command"] = self.agregar
        self.but1.pack({"side": "top"})       



        self.text3 = Text(self)
        self.text3["fg"]   = "white"
        self.text3["bg"]   = "black"
        self.text3["width"]   = 80
        self.text3.pack({"side": "top"})


        self.but2 = Button(self)
        self.but2["text"] = "SALIR"
        self.but2["fg"]   = "white"
        self.but2["bg"]   = "blue"
        self.but2["width"]   = 10
        self.but2["height"]   = 3
        self.but2["border"]   = 4
        self.but2.grid(row = 10, sticky = E, column = 2, pady = 3)
        self.but2["command"] = self.salir
        self.but2.pack({"side": "left"})

        self.but3 = Button(self)
        self.but3["text"] = "LIMPIAR LISTA URL'S"
        self.but3["fg"]   = "white"
        self.but3["bg"]   = "blue"
        self.but3["width"]   = 30
        self.but3["height"]   = 3
        self.but3["border"]   = 4
        self.but3.grid(row = 10, sticky = E, column = 2, pady = 3)
        self.but3["command"] = self.limpiar
        self.but3.pack({"side": "left"})

     
        self.but4 = Button(self)
        self.but4["text"] = "INICIAR LAS DESCARGAS"
        self.but4["fg"]   = "white"
        self.but4["bg"]   = "blue"
        self.but4["width"]   = 30
        self.but4["height"]   = 3
        self.but4["border"]   = 4
        self.but4.grid(row = 10, sticky = E, column = 2, pady = 3)
        self.but4["command"] =  self.download
        self.but4.pack({"side": "right"})


    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.pack()
        self.createWidgets()
       

myapp = Application()
myapp.master.title("DOWNLOADER EN LINUX - GET LINUX")
myapp.master.geometry("+600+600")
myapp.master.tk_setPalette("black")
myapp.master.resizable(0,0)

myapp.mainloop()

Fuente: http://softwarelibre.org.bo/emeric/weblog/2354.html


En línea


-R IP
:0100
-A 100 
2826:0100 MOV AH,09
2826:0102 MOV DX,109
2826:0105 INT 21
2826:0105 MOV AH,08
2826:0105 INT 21
2826:0107 INT 20
2826:0109 DB 'MI NICK ES CODELIVE.$' 
2826:0127 
-R BX
:0000
-R CX
:20
-N CODELIVE.COM
-W
Shrick

Desconectado Desconectado

Mensajes: 259


Yo no se nada, sino ¿porque pregunto?


Ver Perfil
Re: CREANDO UN DOWNLOADER EN PYTHON
« Respuesta #1 en: 4 Julio 2008, 13:06 pm »

Voy a probar si no te importa ;D , yo conseguí hacer algo parecido en Visual Basic pero hay se quedo :laugh: :laugh: . Ahora estoy mirando en python haber que cosas puedo hacer, ver el code simplemente me deja de piedra, quizá porque incluye interfaz gráfica, que no he tocado prefiero hacerla en otro lenguaje, y asi al mirarlo me agobia, prefiero intentar hacerlo yo mismo porque asi no me entra sensación de agobio, y comprendo mejor el funcionamiento de las cosas.

Aun asi GRACIAS ;D !


En línea

Ubuntu User
Pascal (2008/2009)
C/C++ (2009/¿?)
8080 Assembler (2009/2010)
MIPS I Assembler (2010/¿?)

Todo lo que yo haga o diga esta bajo:



No pertenece ni a mi ni a nadie :P .
dooque

Desconectado Desconectado

Mensajes: 170



Ver Perfil
Re: CREANDO UN DOWNLOADER EN PYTHON
« Respuesta #2 en: 5 Julio 2008, 06:37 am »

q piola q esta!

yo estoy intentando hacer un chat para aprender un poco de GUI y de Tkiner! si algun dia lo temrmino lo subo jajajaja!!

saludos!!
En línea

Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.  -- Kernighan
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
[Python] MP3 Downloader 0.1
Scripting
BigBear 4 2,594 Último mensaje 20 Diciembre 2012, 20:03 pm
por flacc
[Aporte][Python]Linux Magazine Downloader v1.0
Scripting
electrodev 0 2,126 Último mensaje 9 Agosto 2013, 00:08 am
por electrodev
Creando nuestro port Scanner en python!
Scripting
alearea51 1 3,148 Último mensaje 28 Febrero 2015, 22:22 pm
por engel lex
Creando un downloader indecetable que ocupa 2 kbytes « 1 2 »
Análisis y Diseño de Malware
Mad Antrax 12 10,704 Último mensaje 3 Junio 2016, 23:56 pm
por Arnaldo Otegi
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines