Thread: IP adresses
View Single Post
Join Date: May 2005
Posts: 215
Reputation: shanenin is an unknown quantity at this point 
Solved Threads: 16
shanenin shanenin is offline Offline
Posting Whiz in Training

Re: IP adresses

 
0
  #7
Nov 7th, 2005
using pywin32 adding to the clipboard is easy.

  1. import win32clipboard, urllib2
  2.  
  3. # this function just gets the ip from reading page source, and parisng it out
  4. def getip():
  5. webaddress = "http://www.getip.com"
  6. page = urllib2.urlopen(webaddress)
  7. pagetolines = page.readlines()
  8. for i in pagetolines:
  9. if i.find('<title>GetIP') != -1:
  10. ipline = i
  11. break
  12. ip = ipline.split()[-1].replace("</title>","")
  13. return ip
  14.  
  15. clippedtext = getip()
  16.  
  17. # this function just places the ip into the clipboard, it takes its parameter from getip
  18. def clippy(text):
  19. win32clipboard.OpenClipboard()
  20. win32clipboard.EmptyClipboard()
  21. win32clipboard.SetClipboardText(text)
  22. win32clipboard.CloseClipboard()
  23.  
  24. clippy(clippedtext)
In a perfect world exceptions would not be needed.
Reply With Quote