def getSiteCachePath(url):
# Obtiene el dominio principal de la URL
dominio = urlparse.urlparse(url)[1]
logger.debug("[scrapertools.py] dominio="+dominio)
nombres = dominio.split(".")
if len(nombres)>1:
dominio = nombres[len(nombres)-2]+"."+nombres[len(nombres)-1]
else:
dominio = nombres[0]
logger.debug("[scrapertools.py] dominio="+dominio)
# Crea un directorio en la cache para direcciones de ese dominio
siteCachePath = os.path.join( CACHE_PATH , dominio )
if not os.path.exists(CACHE_PATH):
try:
os.mkdir( CACHE_PATH )
except:
logger.error("[scrapertools.py] Error al crear directorio "+CACHE_PATH)
if not os.path.exists(siteCachePath):
try:
os.mkdir( siteCachePath )
except:
logger.error("[scrapertools.py] Error al crear directorio "+siteCachePath)
logger.debug("[scrapertools.py] siteCachePath="+siteCachePath)
return siteCachePath
scrapertools_old.py 文件源码
python
阅读 28
收藏 0
点赞 0
评论 0
评论列表
文章目录