| | |
IP adresses
![]() |
Ok, Im still really shaky w/useing python with other programs. So here is my question, is it possible to create just a very small program that grabs my IP adress, copys it, and then sends it to certain IM buddys? The reason I am asking this is beacause my friends and I play a multiplayer game but, the game requires me to give out my IP to every singe person who wants to play, not to mention I also use a program called teamspeak that requires them to type my ip. If it can't send it to im buddys is it possible to just have it copy it to the clipboard?
Help apprecaited. :cheesy:
Help apprecaited. :cheesy:
Blender is by far the best free 3D computer Graphics program and it is expandable with python! GoTo www.blender3d.org
It might depend on what OS you are using, but here is one way ...
[php]# socket.getaddrinfo returns a list of tuples
# tuple[4][0] of each list element is the IP address
import socket
addrs = socket.getaddrinfo(socket.gethostname(), None)
for addr in addrs:
print addr[4][0]
[/php]
[php]# socket.getaddrinfo returns a list of tuples
# tuple[4][0] of each list element is the IP address
import socket
addrs = socket.getaddrinfo(socket.gethostname(), None)
for addr in addrs:
print addr[4][0]
[/php]
May 'the Google' be with you!
Wait so all i need to do is use that code and it will copy it to my clip board? Or will it just print it in the DOS box? Oh and I am using XP for Windows. And what is a tuples?
Blender is by far the best free 3D computer Graphics program and it is expandable with python! GoTo www.blender3d.org
•
•
Join Date: May 2005
Posts: 215
Reputation:
Solved Threads: 16
This is not very efficient, but you could get your ip using a webbased service
I am not sure how to get that on you clipboard.
Python Syntax (Toggle Plain Text)
import urllib2 def getip(): webaddress = "http://www.getip.com" page = urllib2.urlopen(webaddress) pagetolines = page.readlines() for i in pagetolines: if i.find('<title>GetIP') != -1: ipline = i break ip = ipline.split()[-1].replace("</title>","") return ip print getip()
I am not sure how to get that on you clipboard.
In a perfect world exceptions would not be needed.
•
•
Join Date: May 2005
Posts: 215
Reputation:
Solved Threads: 16
•
•
•
•
Originally Posted by vegaseat
It might depend on what OS you are using, but here is one way ...
[php]# socket.getaddrinfo returns a list of tuples
# tuple[4][0] of each list element is the IP address
import socket
addrs = socket.getaddrinfo(socket.gethostname(), None)
for addr in addrs:
print addr[4][0]
[/php]
In a perfect world exceptions would not be needed.
Good question, I am not familiar with the program called teamspeak.
The socket module brings up both IPs on Windows as long as you are connected, otherwise only the internal IP.
You might have to go to wxPython to handle the ClipBoard.
A tuple is an immutable collection of objects separated by commas, usually enclosed in (). In the socket code just print addrs to see what it looks like.
The socket module brings up both IPs on Windows as long as you are connected, otherwise only the internal IP.
You might have to go to wxPython to handle the ClipBoard.
A tuple is an immutable collection of objects separated by commas, usually enclosed in (). In the socket code just print addrs to see what it looks like.
Last edited by vegaseat; Nov 7th, 2005 at 3:12 pm.
May 'the Google' be with you!
•
•
Join Date: May 2005
Posts: 215
Reputation:
Solved Threads: 16
using pywin32 adding to the clipboard is easy.
Python Syntax (Toggle Plain Text)
import win32clipboard, urllib2 # this function just gets the ip from reading page source, and parisng it out def getip(): webaddress = "http://www.getip.com" page = urllib2.urlopen(webaddress) pagetolines = page.readlines() for i in pagetolines: if i.find('<title>GetIP') != -1: ipline = i break ip = ipline.split()[-1].replace("</title>","") return ip clippedtext = getip() # this function just places the ip into the clipboard, it takes its parameter from getip def clippy(text): win32clipboard.OpenClipboard() win32clipboard.EmptyClipboard() win32clipboard.SetClipboardText(text) win32clipboard.CloseClipboard() clippy(clippedtext)
In a perfect world exceptions would not be needed.
How about Tkinter I've learned basic programming in that but i dont know if i can learn wx Python or Pywin32 but if i have to then i dont mind learning that in place of Tkinter.
Blender is by far the best free 3D computer Graphics program and it is expandable with python! GoTo www.blender3d.org
•
•
•
•
Originally Posted by vegaseat
Good question, I am not familiar with the program called teamspeak.
The socket module brings up both IPs on Windows as long as you are connected, otherwise only the internal IP.
You might have to go to wxPython to handle the ClipBoard.
A tuple is an immutable collection of objects separated by commas, usually enclosed in (). In the socket code just print addrs to see what it looks like.
Blender is by far the best free 3D computer Graphics program and it is expandable with python! GoTo www.blender3d.org
Oh and I am reeeeeeeeeeaaaaaaaaaalllllllly shaky with using classes, that is probably the thing I am most having trouble with when it comes to Python and Tkinter.[I just can't fully grasp the consept (ie. don;t understand why self is in there that really bugs me)]
Blender is by far the best free 3D computer Graphics program and it is expandable with python! GoTo www.blender3d.org
![]() |
Similar Threads
- E-mail adresses on phpBB (Geeks' Lounge)
- form to get e-mail and name --- for newsletter (HTML and CSS)
- getting email adress from logon_user (ASP)
- XPpro to WinME networking from hell :( (Networking Hardware Configuration)
- Hijack Log... Tryed everything I can think of. (Viruses, Spyware and other Nasties)
- static ip? (Networking Hardware Configuration)
- how do i get system32 not to open when computer starts (Windows NT / 2000 / XP)
- want to install new Primary Master W2K (Windows NT / 2000 / XP)
- Error Linking KeyLogger.exe (C++)
Other Threads in the Python Forum
- Previous Thread: GnomeDruid class
- Next Thread: File Interactions
| Thread Tools | Search this Thread |
alarm ansi anydbm app assignment backend beginner binary bluetooth character cipher cmd coordinates customdialog cx-freeze data decimals development directory dynamic exe feet file float format function generator getvalue gnu graphics halp handling heads homework http ideas input ip itunes java keycontrol leftmouse line linux list lists loop maintain maze millimeter module mouse number numbers output parsing path pointer prime programming progressbar push py2exe pygame pymailer python queue random recursion recursive schedule screensaverloopinactive script slicenotation sqlite ssh statistics string strings sudokusolver text thread time tlapse tuple ubuntu unicode url urllib urllib2 variable ventrilo vigenere web webservice wikipedia write wxpython xlib xlwt






