import os

def search_word_in_html_files(directory, word):
    files_without_word = []

    for root, _, files in os.walk(directory):
        for file in files:
            if file.endswith('.html'):
                file_path = os.path.join(root, file)
                with open(file_path, 'r', encoding='utf-8') as html_file:
                    content = html_file.read()
                    if word not in content:
                        files_without_word.append(file_path)

    return files_without_word

def generate_html_report(word, files_without_word, output_file):
    html_content = f"""
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Word Search Report</title>
    </head>
    <body>
        <h1>Word Search Report</h1>
        <p>Word: {word}</p>
        <h2>Files Not Containing the Word:</h2>
        <ul>
    """

    for file_path in files_without_word:
        html_content += f'<li><a href="file://{os.path.abspath(file_path)}">{file_path}</a></li>'

    html_content += """
        </ul>
    </body>
    </html>
    """

    with open(output_file, 'w', encoding='utf-8') as file:
        file.write(html_content)

def main():
    word = input("Enter the word to search for: ")
    directory = './'  # Directory containing the .html files
    output_file = 'find-count-words-not-present.html'  # Output HTML file

    files_without_word = search_word_in_html_files(directory, word)
    generate_html_report(word, files_without_word, output_file)

    print(f"Report generated: {output_file}")

if __name__ == "__main__":
    main()
