Ejemplo n.º 1
0
 
 #Enlace a mas informacion
 enlace_nombre= centro.find ("div", "campListNOMBRE")
 enlace_centro = enlace_nombre.a["href"]
 nom_centro=enlace_nombre.a.string.strip()
 
 #Codigo del centro
 div_cod_centro= centro.find ("div", "campListCENTID")
 cod_centro=div_cod_centro.string.strip()
 cod_centro=cod_centro.replace("[", "")
 cod_centro=cod_centro.replace("]", "")
 #Se descarga el fichero ampliado
 url_informacion_centro = URL_JUNTA + enlace_centro
 fichero_mas_informacion=NOMBRE_FICHERO_INFORMACION_CENTRO.format (cod_centro)
 if not gf.existe_fichero ( fichero_mas_informacion ):
     gf.descargar_fichero (url_informacion_centro, fichero_mas_informacion)
 
 div_dir_postal=centro.find("div", "campListDOMICILIO")
 dir_postal=div_dir_postal.string.strip()
 
 
 div_cod_postal=centro.find("div", "campListCP")
 cod_postal=div_cod_postal.string.strip()[4:]
 
 div_localidad=centro.find("div", "campListLOCALIDAD")
 nombre_localidad=div_localidad.string.strip()
 nom_localidad=rectificar_nombre_localidad(nombre_localidad)
 try:
     localidad_asociada=Localidad.objects.get(nombre_localidad=nom_localidad)
     
 except :
#!/usr/bin/env python3


import os, sys
DIR_UTILIDADES=".." + os.sep + "utilidades" + os.sep + "src"
sys.path.insert ( 0, DIR_UTILIDADES )
from utilidades.ficheros.GestorFicheros import GestorFicheros
from constantes import *

gf=GestorFicheros()
gf.crear_directorio ( SUBDIRECTORIO_HTML )

for i in range(0, TOTAL_PAGINAS):
    num = i*3
    url_descarga        = URL_PAGINAS_AL.format ( num )
    fichero_destino     = FICHERO_BASE_AL.format ( i )
    if not gf.existe_fichero( fichero_destino ):
        gf.descargar_fichero(url_descarga, fichero_destino)
Ejemplo n.º 3
0
#!/usr/bin/env python3
#coding=utf-8

from utilidades.ficheros.GestorFicheros import GestorFicheros
import constantes
import bs4, glob, os
from mako.template import Template

gf=GestorFicheros()

for i in range(0, 14):
    FICHERO_DESTINO=constantes.RUTA_FICHEROS_DESCARGADOS.format(i)
    if not gf.existe_fichero ( FICHERO_DESTINO ): 
        gf.descargar_fichero (constantes.URL_BASE.format ( i ),
                          FICHERO_DESTINO)
        
        
contador_comics=0
for i in range(0, 14):
    FICHERO_A_PROCESAR=constantes.RUTA_FICHEROS_DESCARGADOS.format(i)
    sopa=bs4.BeautifulSoup ( open(FICHERO_A_PROCESAR, "r"), "html5lib" )
    divs_miniatura=sopa.find_all("div", "bg_comic")
    for div in divs_miniatura:
        enlace=div.find("a")
        URL_COMIC = constantes.URL + enlace["href"]
        print (URL_COMIC)
        COMIC_DESCARGA=constantes.RUTA_COMICS_DESCARGADOS.format ( contador_comics )
        if not gf.existe_fichero ( COMIC_DESCARGA ):
            gf.descargar_fichero ( URL_COMIC, COMIC_DESCARGA )
        contador_comics=contador_comics + 1