n225-saved-pages/decode.py
Juhani Krekelä 4f22a2117a First commit
2024-12-04 19:44:14 +02:00

21 lines
718 B
Python

import struct
import sys
with open(sys.argv[1], 'rb') as f:
header_len, unknown, mimetype_trailer_len, url_len, name_len = struct.unpack('<IIIII', f.read(20))
assert 20 + mimetype_trailer_len + url_len + name_len == header_len
print(f'header length: {header_len}')
print(f'unknown: {unknown:04x}')
print(f'mimetype trailer length: {mimetype_trailer_len}')
mimetype_trailer = f.read(mimetype_trailer_len).decode('utf-8')
print(f'\t{mimetype_trailer}')
print(f'url lenght: {url_len}')
url = f.read(url_len).decode('utf-8')
print(f'\t{url}')
print(f'name length: {name_len}')
name = f.read(name_len).decode('utf-16-le')
print(f'\t{name}')
html = f.read()
with open(sys.argv[2], 'wb') as f:
f.write(html)