Modify the following python code to also include listing the top subreddit categories that match the keyword:

import praw
import os
from datetime import datetime
import webbrowser # Import the webbrowser module
import time # Import time module to add a slight delay if needed

# Initialize Reddit instance with your credentials
reddit = praw.Reddit(
client_id=os.environ['REDDIT_CLIENT_ID'],
client_secret=os.environ['REDDIT_CLIENT_SECRET'],
user_agent=os.environ['REDDIT_USER_AGENT']
)

# Get keyword from user input
keyword_input = input("Enter the keyword to search for: ")

# Construct the search query using advanced search operators
keyword = f'title:"{keyword_input}"'

# Search entire posts for the keyword
# keyword = f'"{keyword_input}"'

# Search Reddit for submissions containing the keyword in the title, sorted by new
submissions = reddit.subreddit('all').search(keyword, sort='new', syntax='lucene', time_filter="day", limit=100)

# submissions = reddit.subreddit('all').search(keyword, sort='new', syntax='lucene', time_filter='month', limit=100)
# Valid options for time_filter are 'all', 'day', 'hour', 'month', 'week', and 'year'

# Search Reddit (in specific subreddits) for submissions containing the keyword, sorted by new
# subreddit_list = ['Sat', 'SATprep', 'ApplyingToCollege']
# subreddits = '+'.join(subreddit_list)
# submissions = reddit.subreddit(subreddits).search(keyword, sort='new', syntax='lucene', limit=100)

# Define the filename for the HTML file
html_filename = 'reddit_search_results.html'

# Open an HTML file to write the output
with open(html_filename, 'w', encoding='utf-8') as html_file:
# Write the initial HTML structure
html_file.write('<!DOCTYPE html>\n')
html_file.write('<html lang="en">\n')
html_file.write('<head>\n')
html_file.write(' <meta charset="UTF-8">\n')
html_file.write(' <meta name="viewport" content="width=device-width, initial-scale=1.0">\n')
html_file.write(f' <title>Reddit Search Results for "{keyword_input}"</title>\n')
html_file.write('</head>\n')
html_file.write('<body>\n')
html_file.write(f' <h1>Reddit Search Results for "{keyword_input}"</h1>\n')
html_file.write(' <ul>\n')

# Iterate over submissions and write each one to the HTML file
for submission in submissions:
title = submission.title
url = f'https://www.reddit.com{submission.permalink}'
subreddit = submission.subreddit.display_name
created_at = submission.created_utc

# Convert the timestamp to a readable format
created_at_readable = datetime.fromtimestamp(
created_at
).strftime('%Y-%m-%d %H:%M:%S')

# Write the submission details to the HTML file
html_file.write(' <li>\n')
html_file.write(f' <a href="{url}" target="_blank">{title}</a><br>\n')
html_file.write(f' Subreddit: {subreddit}<br>\n')
html_file.write(f' Created at: {created_at_readable}\n')
html_file.write(' </li>\n')
html_file.write(' <hr>\n')

# Close the HTML structure
html_file.write(' </ul>\n')
html_file.write('</body>\n')
html_file.write('</html>\n')

print('Search results have been saved to "reddit_search_results.html".')

# Optional: Wait for a moment to ensure the file is saved
time.sleep(1)

# Get the absolute path to the HTML file
html_file_path = os.path.abspath(html_filename)

# Open the HTML file in Chrome

# Option 1: Open with default browser
# webbrowser.open_new_tab(html_file_path)

# Option 2: Open with Chrome specifically
# Replace the path below with the actual path to your Chrome executable

chrome_exe_path = 'C:/Program Files/Google/Chrome/Application/chrome.exe'

# Check if Chrome exists at the specified path
if os.path.exists(chrome_exe_path):
# Enclose the path in quotes to handle spaces
browser = webbrowser.get(f'"{chrome_exe_path}" %s')
browser.open_new_tab(html_file_path)
else:
print("Chrome browser not found at the specified path. Opening with the default browser.")
webbrowser.open_new_tab(html_file_path)