using pywin32 adding to the clipboard is easy.
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.