[Python-es] Guardar y consultar posteriormente episodios ya descargados.

Alberto Curro bertothunder en gmail.com
Jue Dic 12 11:33:40 CET 2013


El 9 de diciembre de 2013 21:04, Manuel <malvarez99 en gmail.com> escribió:

> Buenas noches a todos.
>
> Estoy dando mis primeros pasos en Python, he conseguido hacer un script
> para bajar series de anime, pero me gustaría guardar en un archivo de texto
> las descargas ya realizadas, así la próxima vez que se ejecutara, mire en
> el archivo de texto para no descargar el mismo episodio.
>
> Este es el código de lo que tengo hecho.
>
> #!/usr/bin/python
> import re, urllib
> import webbrowser
> import time
>
>
> def descarga_anime():
>     lista_anime = ["coppelion", "flamenco", "freezing", "hajime",
> "log-horizon", "valvrave", "arpeggio"]
>     myurl = "http://www.animetake.com"
>
>     for i in re.findall('''href=["'](.[^"']+)["']''',
> urllib.urlopen(myurl).read(), re.I):
>         #time.sleep(900)
>         for serie in lista_anime:
>
>             if serie in i and "episode" in i:
>                 webbrowser.open(i)
>                 time.sleep(4)
>
>                 for torrent in re.findall('''href=["'](.[^"']+)["']''',
> urllib.urlopen(i).read(), re.I):
>                    if "nyaa.se" in torrent:
>                        if "#038" in torrent:
>                            torrent = torrent.replace("#038;", "")
>                        torrent = torrent.replace("amp;", "").replace(" ",
> "")
>                        webbrowser.open(torrent)
>                        time.sleep(4)
>                        break
>
> descarga_anime()
>
>
> Muchas gracias por vuestro tiempo y ayuda.
> Manuel.
>
> _______________________________________________
> Python-es mailing list
> Python-es en python.org
> https://mail.python.org/mailman/listinfo/python-es
> FAQ: http://python-es-faq.wikidot.com/
>

Por qué el break al final del for??? Sólo esperas encontrar en la lista un
candidato a substitución?

Por otro lado, google es tu amigo:

http://docs.python.org/2/tutorial/inputoutput.html
http://stackoverflow.com/questions/899103/python-write-a-list-to-a-file
http://www.afterhoursprogramming.com/tutorial/Python/Writing-to-Files/

Saludos
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://mail.python.org/pipermail/python-es/attachments/20131212/fea111b1/attachment.html>


Más información sobre la lista de distribución Python-es