python links with href code example
Example 1: Following Links in Python
import urllib
from BeautifulSoup import *
URL = raw_input("Enter the URL:")
link_line = int(raw_input("Enter position:")) - 1
count = int(raw_input("Enter count:"))
while count >= 0:
html = urllib.urlopen(URL).read()
soup = BeautifulSoup(html)
tags = soup('a')
print URL
URL = tags[link_line].get("href", None)
count = count - 1
Example 2: how to set a hyperlink in python
from tkinter import *
canvas1=Tk()
Label(canvas1, text="canvas1").grid(row=0, column=0)
OPEN_HYP=Button(canvas1, text="OPEN", command:enter(canvas1)).grid(row=1, column=0)
def enter():
canvas2()
def canvas2():
canvas2=Tk()
Label(canvas2, text="canvas2").grid(row=0, column=0)