Spaces:
Sleeping
Sleeping
import os | |
from selenium import webdriver | |
from selenium.webdriver.chrome.options import Options | |
from ascii_magic import AsciiArt | |
def capture_screenshot(url, output_path='screenshot.png'): | |
# Set up headless Chrome | |
chrome_options = Options() | |
chrome_options.add_argument('--headless') | |
chrome_options.add_argument('--disable-gpu') | |
chrome_options.add_argument('--window-size=1920,1080') | |
# Initialize WebDriver | |
driver = webdriver.Chrome(options=chrome_options) | |
driver.get(url) | |
# Save screenshot | |
driver.save_screenshot(output_path) | |
driver.quit() | |
def convert_to_ascii(image_path): | |
# Create an AsciiArt instance from the image file | |
my_art = AsciiArt.from_image(image_path) | |
# Display the ASCII art in the terminal | |
my_art.to_terminal(columns=100, monochrome=True) | |
if __name__ == '__main__': | |
url = input("Enter the website URL (e.g., https://example.com): ").strip() | |
screenshot_file = 'screenshot.png' | |
print(f"\nCapturing screenshot of {url}...") | |
capture_screenshot(url, screenshot_file) | |
print("\nConverting screenshot to ASCII art:\n") | |
convert_to_ascii(screenshot_file) | |
# Optional: Remove the screenshot file after conversion | |
os.remove(screenshot_file) | |