I used Python code in the past to retrieve search result from Youtube. I tried to use the same code again, however the HTML seems to be an empty skeleton:
import urllib.request
from bs4 import BeautifulSoup
def url_to_video(text_to_search):
query = urllib.parse.quote(text_to_search)
url = "https://www.youtube.com/results?search_query=" + query
response = urllib.request.urlopen(url)
html = response.read()
response.close()
soup = BeautifulSoup(html, 'html.parser')
url_list = []
for vid in soup.findAll(attrs={'class': 'yt-uix-tile-link'}):
url_list.append('https://www.youtube.com' + vid['href'])
return url_list
Did Youtube find a way to block webscraping? Is there a working alternative?