How To Get Your IP Address In Vanilla Python TUTORIAL
Vložit
- čas přidán 2. 07. 2024
- In this tutorial I will be showing you how you can get your IP address in vanilla Python. It's super easy!
▶ Become job-ready with Python:
www.indently.io
▶ Follow me on Instagram:
/ indentlyreels
Bet your soft is absolutely amazing! Never give up
❤️
how u can change ur orginal ip address in the vpn with the help of the python ?
Of course, as you can do almost everything in python. But there is no universal way of doing this. The best thing you could do is proxy requests ("requests" module) using the "proxies=" keyword argument when calling each type of request.
How did you type that arrow at 0:43?
that means you are returning a string, so type(get_ip(some_variable)) will be a string however, python is dynamically typed, so it’s only to see for other programmers what we can get from this function
Its just a minus and a greater than, the font automatically joins them together to seem like a single character
I have this problem with tkinter. Can u help me?
File "c:\Users\jp\Desktop\Python_3.10\tk.py", line 1, in
import tkinter
File "c:\Users\jp\Desktop\Python_3.10\tkinter.py", line 8, in
window = tk()
^^^^
TypeError: 'module' object is not callable
What exactly is tk? Did you import tkinter as tk? If so, you need to do tk.Tk() instead.
if you imported tkinter with "import tkinter as tk", do "window = tk.Tk()", otherwise you'll get errors
@@_lun4r_ Also, if you did not import Tkinter with a special name just do "window = tkinter.Tk()".
Even we can access our local ip address from sockets too: @Indently
import socket
get_ip = lambda : socket.gethostbyname(socket.gethostname())
print(get_ip())
Yeah local is straightforward, getting the public, not so much.
import socket
hostname = socket.gethostname()
IPadd = socket.gethostbyname(hostname)
print(IPadd)
Here we go, make your code simple
1) It's not vanilla Python
2) It only returns your private IP Address
@@Indently wtf
what do you mean by vanilla python
I'd argue that 'socket' is more vanilla than urlib because urlib uses sockets
but yes it is impossible to get the public IP of the NAT gateway of your LAN with only local socket operations.
@@royler8848 You're absolutely right, my first point was a very poor choice of words. You got me there.