title: Beautifulsoup decompose()
body: <p>I'm trying to get rid of <code>&lt;script&gt;</code> tags and the content inside the tag utilizing beatifulsoup. I went to the documentation and seems to be a really simple function to call. More information about the function is <a href="https://www.crummy.com/software/BeautifulSoup/bs4/doc/#decompose" rel="noreferrer">here</a>. Here is the content of the html page that I have parsed so far...</p>
  
  <pre><code>&lt;body class="pb-theme-normal pb-full-fluid"&gt;
      &lt;div class="pub_300x250 pub_300x250m pub_728x90 text-ad textAd text_ad text_ads text-ads text-ad-links" id="wp-adb-c" style="width: 1px !important;
      height: 1px !important;
      position: absolute !important;
      left: -10000px !important;
      top: -1000px !important;
      "&gt;
  &lt;/div&gt;
  &lt;div id="pb-f-a"&gt;
  &lt;/div&gt;
      &lt;div class="" id="pb-root"&gt;
      &lt;script&gt;
      (function(a){
          TWP=window.TWP||{};
          TWP.Features=TWP.Features||{};
          TWP.Features.Page=TWP.Features.Page||{};
          TWP.Features.Page.PostRecommends={};
          TWP.Features.Page.PostRecommends.url="https://recommendation-hybrid.wpdigital.net/hybrid/hybrid-filter/hybrid.json?callback\x3d?";
          TWP.Features.Page.PostRecommends.trackUrl="https://recommendation-hybrid.wpdigital.net/hybrid/hybrid-filter/tracker.json?callback\x3d?";
          TWP.Features.Page.PostRecommends.profileUrl="https://usersegment.wpdigital.net/usersegments";
          TWP.Features.Page.PostRecommends.canonicalUrl=""
      })(jQuery);
  
      &lt;/script&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>Imagine you have some web content like that and you have that in a BeautifulSoup object called <code>soup_html</code>. If I run <code>soup_html.script.decompose()</code> and them call the object <code>soup_html</code> the script tags still there. How I can get rid of the <code>&lt;script&gt;</code> and the content inside those tags?</p>
  
  <pre><code>markup = 'The html above'
  soup = BeautifulSoup(markup)
  html_body = soup.body
  
  soup.script.decompose()
  
  html_body
  </code></pre>