#!/usr/bin/env python3 """ Remove hreflang tags that point to dead domains. """ import os import re def remove_hreflang(filepath): with open(filepath, 'r', encoding='utf-8', errors='ignore') as f: content = f.read() original = content # Remove hreflang link tags content = re.sub(r'\s*\n?', '', content) if content != original: with open(filepath, 'w', encoding='utf-8') as f: f.write(content) return True return False def main(): base_dir = "/home/bernt/.openclaw/workspace/landvex-all" count = 0 for root, dirs, files in os.walk(base_dir): for file in files: if file.endswith('.html'): filepath = os.path.join(root, file) if remove_hreflang(filepath): count += 1 rel_path = os.path.relpath(filepath, base_dir) print(f"Removed hreflang: {rel_path}") print(f"\nDone: Removed hreflang from {count} files") if __name__ == "__main__": main()