275aff1430
Los scripts del mirror (00-90) vivian solo en el disco. Van al repo; los datos que generan no (16 GB entre crawl, snapshot del origen y Joomla restaurado) -> .gitignore. Nuevo 91-repone-assets404.sh: repone los ficheros que el crawl no capturo porque se referencian SOLO desde CSS y el crawler seguia enlaces HTML (system.css, los fondos de fe_adulta_1, ratingstars.gif de K2). Salian como 404 en los logs de nginx del Hetzner. Descarga por HTTP desde el Joomla local aislado, nunca del filesystem -- mismo principio que el crawl, para no arrastrar los .php comprometidos del #183 -- y escanea PHP embebido antes de copiar a site/. Resultado sobre las 286 rutas unicas con 404 del log: 196 repuestas y verificadas en produccion (196/196 en 200 tras el rsync), 82 que dan 301->404 tambien en el origen (ya estaban rotas en la web original) y 8 rutas basura /%22/... de HTML mal formado. Refs #180 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
64 lines
2.1 KiB
Python
64 lines
2.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Afina el cruce con Wayback: solo las URLs /es/ (el Joomla legacy), que es lo que el mirror cubre.
|
|
|
|
El 52 % global del script anterior mezcla peras con manzanas: Wayback conoce feadulta.com desde
|
|
antes de que existiera el Joomla (ficheros .htm sueltos en la raiz, que hoy viven bajo /anterior/) y
|
|
tambien el WordPress actual (/wp-content, /wp-json). Nada de eso forma parte del mirror del legacy.
|
|
"""
|
|
import os, json, re
|
|
from collections import Counter
|
|
from urllib.parse import urlsplit, unquote
|
|
|
|
BASE = "/home/rafa/joomla-migration/mirror-antiguo"
|
|
RUN = open(os.path.join(BASE, "CURRENT_RUN")).read().strip()
|
|
DIR = os.path.join(BASE, "runs", RUN)
|
|
SITE = os.path.join(DIR, "site", "antiguo.feadulta.com")
|
|
|
|
def existe(path):
|
|
p = unquote(path).lstrip("/")
|
|
for c in (p, p.split("?", 1)[0], os.path.join(p, "index.html")):
|
|
if c and os.path.isfile(os.path.join(SITE, c)):
|
|
return True
|
|
return False
|
|
|
|
paths = set()
|
|
for fn in ("wayback-antiguo.txt", "wayback-feadulta.txt"):
|
|
for line in open(os.path.join(BASE, "inventory", fn), errors="replace"):
|
|
u = line.strip()
|
|
if not u:
|
|
continue
|
|
s = urlsplit(u)
|
|
if s.query:
|
|
continue
|
|
if s.path.startswith("/es/"):
|
|
paths.add(s.path)
|
|
|
|
ok, missing = 0, []
|
|
for p in sorted(paths):
|
|
if existe(p):
|
|
ok += 1
|
|
else:
|
|
missing.append(p)
|
|
|
|
print("URLs /es/ conocidas por Wayback:", len(paths))
|
|
print("resuelven en el mirror:", ok, "(%.1f%%)" % (ok * 100.0 / max(len(paths), 1)))
|
|
print("no resuelven:", len(missing))
|
|
|
|
tipo = Counter()
|
|
for p in missing:
|
|
seg = p.split("/")
|
|
tipo["/".join(seg[:3])] += 1
|
|
print("\n--- las que faltan, por seccion ---")
|
|
for k, v in tipo.most_common(15):
|
|
print("%7d %s" % (v, k))
|
|
|
|
json.dump({"wayback_es_paths": len(paths), "presentes": ok, "ausentes": len(missing),
|
|
"pct": round(ok * 100.0 / max(len(paths), 1), 2)},
|
|
open(os.path.join(DIR, "wayback-es-report.json"), "w"), indent=2)
|
|
with open(os.path.join(DIR, "wayback-es-missing.txt"), "w") as f:
|
|
for p in missing:
|
|
f.write(p + "\n")
|
|
print("\n--- muestra ---")
|
|
for p in missing[:15]:
|
|
print(" ", p)
|