# -*- coding: utf-8 -*- import sys def normalize_file(filepath): with open(filepath, 'r', encoding='utf-8') as f: content = f.read() content = content.lstrip('\ufeff') lines = [line.rstrip() for line in content.splitlines()] norm_lines = [] prev_blank = False for line in lines: if line == '': if not prev_blank: norm_lines.append(line) prev_blank = True else: norm_lines.append(line) prev_blank = False result = '\r\n'.join(norm_lines) + '\r\n' with open(filepath, 'wb') as f: f.write(b'\xef\xbb\xbf' + result.encode('utf-8')) normalize_file('raids/pandemonium_abyssos.html') with open('raids/index.html', 'r', encoding='utf-8') as f: text = f.read() target = """ 煉獄編 1〜4層 Lv90 (IL605〜) ノーマル / 零式 プロトカーバンクル(毒・突進)、ヘーゲモネ、アグディスティス、ヘファイストス(変異創身・概念支配)。 準備中 """ replacement = """ 煉獄編 1〜4層 Lv90 (IL605〜) ノーマル / 零式 プロトカーバンクル(毒・突進)、ヘーゲモネ、アグディスティス、ヘファイストス(変異創身・概念支配)。 攻略を見る ➜ """ if target in text: text = text.replace(target, replacement) with open('raids/index.html', 'w', encoding='utf-8') as f: f.write(text) normalize_file('raids/index.html') print("SUCCESS: Updated raids/index.html with Pandemonium Abyssos link.") else: print("ERROR: Target string not found in raids/index.html")