feat: 死角彷徨 ストレイバロー・デッドウォーク 完全攻略ページの作成および一覧リンク追加

This commit is contained in:
armonica committed 2026-10-29 11:59:06 +09:00
1 parent cf44731c2d
commit 783947dee2
3 files changed
+312 -1

No files matched your search

+37
View File
@@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-
import os
import re
def clean_and_save(path, content):
content = content.replace('\r\n', '\n').replace('\r', '\n')
lines = [line.rstrip() for line in content.split('\n')]
result_lines = []
prev_empty = False
for line in lines:
if line == '':
if not prev_empty:
result_lines.append(line)
prev_empty = True
else:
result_lines.append(line)
prev_empty = False
while result_lines and result_lines[-1] == '':
result_lines.pop()
text = '\r\n'.join(result_lines) + '\r\n'
text = text.lstrip('\ufeff')
with open(path, 'wb') as f:
f.write(b'\xef\xbb\xbf' + text.encode('utf-8'))
def update_dungeon_entry(name_keyword, url):
path_idx = 'dungeons/index.html'
with open(path_idx, 'rb') as f:
c = f.read().decode('utf-8', errors='ignore')
if f'href="{url}"' not in c:
c = c.replace('\r\n', '\n')
c = re.sub(rf'({re.escape(name_keyword)}</strong>.*?<td>)準備中(</td>)', rf'\g<1><a href="{url}">攻略を見る ➜</a>\2', c, flags=re.DOTALL)
clean_and_save(path_idx, c)
print(f"Updated {name_keyword} in {path_idx}")
if __name__ == '__main__':
clean_and_save('dungeons/strayborough.html', open('dungeons/strayborough.html', 'r', encoding='utf-8', errors='ignore').read())
update_dungeon_entry('ストレイバロー・デッドウォーク', 'strayborough.html')