|
import os |
|
from selenium import webdriver |
|
from selenium.webdriver.chrome.options import Options |
|
from PIL import Image |
|
from ascii_magic import from_image_file, to_terminal |
|
|
|
def capture_screenshot(url, output_path='screenshot.png'): |
|
|
|
chrome_options = Options() |
|
chrome_options.add_argument('--headless') |
|
chrome_options.add_argument('--disable-gpu') |
|
chrome_options.add_argument('--window-size=1920,1080') |
|
|
|
|
|
driver = webdriver.Chrome(options=chrome_options) |
|
driver.get(url) |
|
|
|
|
|
driver.save_screenshot(output_path) |
|
driver.quit() |
|
|
|
def convert_to_ascii(image_path): |
|
|
|
output = from_image_file(image_path, columns=100, char='#') |
|
to_terminal(output) |
|
|
|
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) |
|
|
|
|
|
os.remove(screenshot_file) |
|
|