title: BeatifulSoup4 get_text still has javascript
body: <p>I'm trying to remove all the html/javascript using bs4, however, it doesn't get rid of javascript. I still see it there with the text. How can I get around this?</p>
  
  <p>I tried using <code>nltk</code> which works fine however, <code>clean_html</code> and <code>clean_url</code> will be removed moving forward. Is there a way to use soups <code>get_text</code> and get the same result?</p>
  
  <p>I tried looking at these other pages:</p>
  
  <p><a href="https://stackoverflow.com/questions/10524387/beautifulsoup-get-text-does-not-strip-all-tags-and-javascript">BeautifulSoup get_text does not strip all tags and JavaScript</a></p>
  
  <p>Currently i'm using the nltk's deprecated functions.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Here's an example:</p>
  
  <pre><code>import urllib
  from bs4 import BeautifulSoup
  
  url = "http://www.cnn.com"
  html = urllib.urlopen(url).read()
  soup = BeautifulSoup(html)
  print soup.get_text()
  </code></pre>
  
  <p>I still see the following for CNN:</p>
  
  <pre><code>$j(function() {
  "use strict";
  if ( window.hasOwnProperty('safaripushLib') &amp;&amp; window.safaripushLib.checkEnv() ) {
  var pushLib = window.safaripushLib,
  current = pushLib.currentPermissions();
  if (current === "default") {
  pushLib.checkPermissions("helloClient", function() {});
  }
  }
  });
  
  /*globals MainLocalObj*/
  $j(window).load(function () {
  'use strict';
  MainLocalObj.init();
  });
  </code></pre>
  
  <p>How can I remove the js?</p>
  
  <p>Only other options I found are:</p>
  
  <p><a href="https://github.com/aaronsw/html2text" rel="noreferrer">https://github.com/aaronsw/html2text</a></p>
  
  <p>The problem with <code>html2text</code> is that it's really <em>really</em> slow at times, and creates noticable lag, which is one thing nltk was always very good with.</p>