-
Notifications
You must be signed in to change notification settings - Fork 0
/
web_tools(IP,Web_Scraping).py
69 lines (47 loc) · 1.55 KB
/
web_tools(IP,Web_Scraping).py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import requests
import socket
import tkinter as tk
from tkinter import scrolledtext
# Web scraping function
def scrape_website(url):
try:
response = requests.get(url)
if response.status_code == 200:
return response.text
else:
return "Error: Could not scrape website"
except:
return "Error: Could not scrape website"
# Function to get IP address from domain name
def get_ip_address(domain_name):
try:
return socket.gethostbyname(domain_name)
except:
return "Error: Could not get IP address"
# GUI code
window = tk.Tk()
window.title("Web Scraper")
window.geometry("800x600")
url_label = tk.Label(text="Enter website URL:")
url_label.pack()
url_entry = tk.Entry()
url_entry.pack()
scrape_button = tk.Button(text="Scrape Website", command=lambda: show_results(scrape_website(url_entry.get())))
scrape_button.pack()
ip_label = tk.Label(text="IP Address:")
ip_label.pack()
ip_text = scrolledtext.ScrolledText()
ip_text.pack()
def show_results(website_data):
results_text.delete('1.0', tk.END)
results_text.insert(tk.END, website_data)
domain_name = url_entry.get().replace("https://", "").replace("http://", "").split("/")[0]
ip_address = get_ip_address(domain_name)
ip_text.delete('1.0', tk.END)
ip_text.insert(tk.END, ip_address)
results_label = tk.Label(text="Scraped Website:")
results_label.pack()
results_text = scrolledtext.ScrolledText()
results_text.pack()
window.mainloop()
#01Kevin01