title: How to get all links from website using Beautiful Soup (python) Recursively
body: <p>I want to be able to recursively get all links from a website then follow those links and get all links from those websites. The depth should be 5-10 so that it returns back a an array of all links that it finds. Preferably using beautiful soup/python. Thanks!</p>
  
  <p>I have tried this so far and it is not working....any help will be appreciated.</p>
  
  <pre><code>from BeautifulSoup import BeautifulSoup
  import urllib2
  
  def getLinks(url):
      if (len(url)==0):
          return [url]
      else:
          files = [ ]
          page=urllib2.urlopen(url)
          soup=BeautifulSoup(page.read())
          universities=soup.findAll('a',{'class':'institution'})
          for eachuniversity in universities:
             files+=getLinks(eachuniversity['href'])
          return files
  
  print getLinks("http://www.utexas.edu/world/univ/alpha/")
  </code></pre>