-3

I want to get the title of a youtube video by url. I have been searching for several days but I did not get the result

I have been searching for several days but I did not get the result

1 Answers1

2

By using requests and Beautiful Soup libraries you can achieve that:

import requests
from bs4 import BeautifulSoup

r = requests.get("https://www.youtube.com/watch?v=9sg-A-eS6Ig&list=RDBAkqJT_sMKQ&index=5")
soup = BeautifulSoup(r.text)

link = soup.find_all(name="title")[0]
title = str(link)
title = title.replace("<title>","")
title = title.replace("</title>","")

print(title)
STM
  • 51
  • 2