I want to extract video information(like title, viewer's counts) of a certain Youtube video using python, just as I did web scrapping on other websites. But for some reason, either it returns nothing or provides tags only for recommended videos on the side instead of "the main video" of the URL
I tried the same codes that I used for web-scrapping on other websites as below. Apparently it doesn't work on Youtube. What should I do if I want to get video information based on a youtube URL?
import requests
from bs4 import BeautifulSoup
base_url ='https://www.youtube.com/watch?'
search_string = 'v=I41aLSzLI50'
url = base_url + search_string
supers=requests.get(url).content
data = BeautifulSoup(supers,'html.parser')
videos =data.find_all('a', class_= 'content-link spf-link yt-uix-sessionlink spf-link')
for video in videos:
print(video.find('span', class_='title').get_text())
Aucun commentaire:
Enregistrer un commentaire