|
| 1 | +import tkinter as tk |
| 2 | +from urllib.request import urlopen |
| 3 | +from http import HTTPStatus |
| 4 | +from fake_useragent import UserAgent |
| 5 | + |
| 6 | +def get_status(status_code: int) -> str: |
| 7 | + for value in HTTPStatus: |
| 8 | + if value.value == status_code: |
| 9 | + description = f'({value.value} {value.name}) {value.description}' |
| 10 | + return description |
| 11 | + return "Unknown Status Code..." |
| 12 | + |
| 13 | +def check_website(): |
| 14 | + website_url = website_entry.get() |
| 15 | + result_text.delete("1.0", tk.END) |
| 16 | + |
| 17 | + try: |
| 18 | + response = urlopen(website_url) |
| 19 | + status_code = response.getcode() |
| 20 | + status_description = get_status(status_code) |
| 21 | + result = f"Status for {website_url}:\n{status_description}\n" |
| 22 | + except Exception as e: |
| 23 | + result = f"Error checking {website_url}:\n{str(e)}\n" |
| 24 | + |
| 25 | + result_text.insert(tk.END, result) |
| 26 | + |
| 27 | +root = tk.Tk() |
| 28 | +root.title("Website Checker") |
| 29 | +root.configure(bg="#1e1e1e") |
| 30 | + |
| 31 | +website_label = tk.Label(root, text="Enter Website URL:", bg="#1e1e1e", fg="white") |
| 32 | +website_label.pack(pady=5) |
| 33 | + |
| 34 | +website_entry = tk.Entry(root, width=50) |
| 35 | +website_entry.pack(pady=5) |
| 36 | + |
| 37 | +check_button = tk.Button(root, text="Check Website", command=check_website, bg="#303030", fg="white") |
| 38 | +check_button.pack(pady=5) |
| 39 | + |
| 40 | +result_text = tk.Text(root, wrap=tk.WORD, bg="#1e1e1e", fg="white") |
| 41 | +result_text.pack(fill=tk.BOTH, expand=True) |
| 42 | + |
| 43 | +root.mainloop() |
0 commit comments