title: Get the text from a YouTube page with bs4
body: <p>I would love some help, thanks!</p>
  
  <p>I am trying to get only the text from a YouTube page with no success, it's giving me something, but it's not the text.</p>
  
  <p>I tried the code on several URLs of YouTube and it's giving me pretty much the same outputs, also, i tried the code on different URLs(not YouTube) and it gave me the text of the website. </p>
  
  <p>The code:</p>
  
  <pre><code> # -*- coding: utf-8 -*-
  import urllib.request
  from bs4 import BeautifulSoup
  def read_url(url):
      headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987 Safari/537.36'}
      request = urllib.request.Request(url,headers=headers)
      html = urllib.request.urlopen(request,timeout=5).read()
      return html
  def parse(html):
      soup = BeautifulSoup(html,features='lxml')
      for script in soup(["script", "style",'[document]','head', 'title','\n']):
          script.extract()
      data = soup.get_text()
      return data
  
  def get_text(url):
      html = read_url(url)
      text = parse(html)
      return text
  
  def main():
      url = 'https://www.youtube.com/watch?v=2lAe1cqCOXo'
      print(get_text(url))
  
  
  if __name__ == '__main__':
      main()
  </code></pre>
  
  <p>The output:</p>
  
  <pre><code>About
  Press
  Copyright
  Contact us
  Creators
  Advertise
  Developers
  Terms
  Privacy
  Policy &amp; Safety
  Test new features
  </code></pre>