title: How to count total number of particular word on the website?
body: <p>I am developing a small program which goes through a website and find a a word based on user input and counts how many times the word has occurred on webpage.</p>
  
  <p>Here is my try below:</p>
  
  <pre><code>from urllib.request import urlopen
  from html.parser import HTMLParser
  
  class NeedstobeParser(HTMLParser):
      sites = []
      def handle_starttag(self, tag, attrs):
          if tag == "a":
              for attr in attrs:
                  if attr[0] == "href":
                      self.sites.append(attr[1])
  
      def get_sites(self):
          return self.sites
  
  website = urlopen('http://worldfacts.us')
  html = website.read()
  content = html.decode()
  
  Parser = NeedstobeParser()
  Parser.feed(content)
  sites = Parser.get_sites()
  country_sites = []
  
  
  for countries in sites:
      countries = countries.replace("http://worldfacts.us/","")
      countries = countries.replace(".", "")
      countries = countries.replace("-", " ")
      countries = countries.replace("htm","")
      country_sites.append(countries)
  country_sites.remove('map/index')
  country_sites.remove('flag/index')
  
  for i in country_sites:
      print(i)
  
  
  
  while True:
      count_number = 0
      userinput = input("What country would you like to look up?: ")
      if userinput in country_sites:
          url = "http://worldfacts.us/"+userinput+".htm"
          askuser = input('What word would you like to look up?: ')
          for i in url:
              if askuser in url:
                  count_number += 1
                  print(count_number)
  </code></pre>
  
  <blockquote>
  <pre><code>#this second try instead of for loop
              margo = url.count("'"+askuser+"'")
              count_number = count_number + margo
  </code></pre>
  </blockquote>
  
  <pre><code>        print("The word " + "'"+askuser+"'" + " shows up " + str(count_number) + " time(s) on " + url)
          break
      else:
          print('Error. '+ "'"+userinput+"'" +' not found.')
  </code></pre>
  
  <p>both of the tries give me '0' result but I am sure 100% that the word which user typed in is contains on the webpage.</p>