def search_youtube(text):
url = 'https://www.youtube.com'
while True:
r = requests.get(url + '/results', params={'search_query': text})
soup = BeautifulSoup(r.content, 'html.parser')
tag = soup.find('a', {'rel': 'spf-prefetch'})
title, video_url = tag.text, url + tag['href']
if 'googleads' not in video_url:
break
return title, video_url
评论列表
文章目录