title: BeautifulSoup get_text does not strip all tags and JavaScript
body: <p>I am trying to use BeautifulSoup to get text from web pages.</p>
  
  <p>Below is a script I've written to do so. It takes two arguments, first is the input HTML or XML file, the second output file.</p>
  
  <pre><code>import sys
  from bs4 import BeautifulSoup
  
  def stripTags(s): return BeautifulSoup(s).get_text()
  
  def stripTagsFromFile(inFile, outFile):
      open(outFile, 'w').write(stripTags(open(inFile).read()).encode("utf-8"))
  
  def main(argv):
      if len(sys.argv) &lt;&gt; 3:
          print 'Usage:\t\t', sys.argv[0], 'input.html output.txt'
          return 1
      stripTagsFromFile(sys.argv[1], sys.argv[2])
      return 0
  
  if __name__ == "__main__":
      sys.exit(main(sys.argv))
  </code></pre>
  
  <p>Unfortunately, for many web pages, for example: <a href="http://www.greatjobsinteaching.co.uk/career/134112/Education-Manager-Location">http://www.greatjobsinteaching.co.uk/career/134112/Education-Manager-Location</a>
  I get something like this (I'm showing only few first lines):</p>
  
  <pre><code>html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
      Education Manager  Job In London With  Caleeda | Great Jobs In Teaching
  
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-15255540-21']);
  _gaq.push(['_trackPageview']);
  _gaq.push(['_trackPageLoadTime']);
  </code></pre>
  
  <p>Is there anything wrong with my script? I was trying to pass 'xml' as the second argument to BeautifulSoup's constructor, as well as 'html5lib' and 'lxml', but it doesn't help.
  Is there an alternative to BeautifulSoup which would work better for this task? All I want is to extract the text which would be rendered in a browser for this web page.</p>
  
  <p>Any help will be much appreciated. </p>