
import requests
from bs4 import BeautifulSoup

YOUTUBE_TRENDING_URL='https://www.youtube.com/feed/trending'

# Doesn't execute the Javascript
response=requests.get(YOUTUBE_TRENDING_URL)

print('Status Code',response.status_code)

# with open('trending.html','w') as f:
#   f.write(response.text)

doc=BeautifulSoup(response.text)

print('Page title :',doc.title.text)

# Find all the video divs
video_divs=doc.find_all('div',class_='ytd-video-renderer')

print(f'Found {len(video_divs)} videos')

import requests
from bs4 import BeautifulSoup

YOUTUBE_TRENDING_URL='https://www.youtube.com/feed/trending'

# Doesn't execute the Javascript
response=requests.get(YOUTUBE_TRENDING_URL)

print('Status Code',response.status_code)

# with open('trending.html','w') as f:
#   f.write(response.text)

doc=BeautifulSoup(response.text)

print('Page title :',doc.title.text)

# Find all the video divs
video_divs=doc.find_all('div',class_='ytd-video-renderer')

print(f'Found {len(video_divs)} videos')
# Doesn't execute the Javascript # with open('trending.html','w') as f: #   f.write(response.text) # Find all the video divs