Skip to content

Commit fae4035

Browse files
Merge pull request #2318 from singhchanmeet/ip-from-hostname
Added IP from Hostname Script
2 parents 0a8911d + 7202434 commit fae4035

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

IP from Hostname/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# IP from Hostname
2+
3+
## 📝 Description
4+
* This Python script takes a URL as an input and returns the corresponding IP address
5+
* The script uses <a href="https://docs.python.org/3/library/socket.html">socket library</a> for this purpose
6+
7+
<br>
8+
9+
## ⚙️ How To Use
10+
11+
Navigate to the project directory and run the following command :
12+
```bash
13+
python ip_from_hostname.py
14+
```
15+
16+
## Output Screenshot
17+
18+
<img src="output.png">
19+
20+
## Author
21+
22+
23+
* <a href="https://github.com/singhchanmeet"> Chanmeet Singh </a>
24+
25+

IP from Hostname/ip_from_hostname.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import socket
2+
3+
hostname = input("Enter the URL: ")
4+
5+
try :
6+
ip_address = socket.gethostbyname(hostname)
7+
print(ip_address)
8+
except:
9+
print('Invalid URL')
10+

IP from Hostname/output.png

11.3 KB
Loading

0 commit comments

Comments
 (0)