title: Having problems following links with webcrawler
body: <p>I am trying to create a webcrawler that parses all the html on the page, grabs a specified (via <code>raw_input</code>) link, follows that link, and then repeats this process a specified number of times (once again via <code>raw_input</code>). I am able to grab the first link and successfully print it. However, I am having problems "looping" the whole process, and usually grab the wrong link. This is the first link </p>
  
  <p><a href="https://pr4e.dr-chuck.com/tsugi/mod/python-data/data/known_by_Fikret.html" rel="nofollow">https://pr4e.dr-chuck.com/tsugi/mod/python-data/data/known_by_Fikret.html</a> </p>
  
  <p>(Full disclosure, this questions pertains to an assignment for a Coursera course) </p>
  
  <p>Here's my code </p>
  
  <pre><code>import urllib
  from BeautifulSoup import *
  url = raw_input('Enter - ')
  rpt=raw_input('Enter Position')
  rpt=int(rpt)
  cnt=raw_input('Enter Count')
  cnt=int(cnt)
  count=0
  counts=0
  tags=list()
  soup=None
  while x==0:
      html = urllib.urlopen(url).read()
      soup = BeautifulSoup(html)
  # Retrieve all of the anchor tags
      tags=soup.findAll('a')
      for tag in tags:
          url= tag.get('href')
          count=count + 1
          if count== rpt:
              break
  counts=counts + 1
  if counts==cnt:        
      x==1       
  else: continue
  print  url
  </code></pre>