Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- # Filename: html2bin.py
- # Version: 1.0.0
- # Author: Jeoi Reqi
- """
- Description:
- This script converts an HTML file (.html) to a binary file (.bin).
- It reads the HTML content and writes it to a binary file after encoding it in UTF-8.
- Requirements:
- - Python 3.x
- Usage:
- 1. Save this script as 'html2bin.py'.
- 2. Ensure your HTML file ('example.html') is in the same directory as the script.
- 3. Run the script.
- 4. The converted binary file ('html2bin.bin') will be generated in the same directory.
- Note: Adjust the 'html_filename' and 'bin_filename' variables in the script as needed.
- """
- def html_to_bin(html_filename, bin_filename):
- with open(html_filename, 'r') as htmlfile, open(bin_filename, 'wb') as binfile:
- binfile.write(htmlfile.read().encode('utf-8'))
- if __name__ == "__main__":
- html_filename = 'example.html'
- bin_filename = 'html2bin.bin'
- html_to_bin(html_filename, bin_filename)
- print(f"Converted '{html_filename}' to '{bin_filename}'.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement