Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
from bs4 import BeautifulSoup
import requests, lxml
headers = {
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36"
params = {
"q": "somebody toucha my spaghet",
"cc": "us" # language/country of the search
html = requests.get('', params=params, headers=headers)
soup = BeautifulSoup(html.text, 'lxml')
for result in'.mc_vtvc.b_canvas'):
title = result.select_one('.b_promtxt').text
link = f"{result.select_one('.mc_vtvc_link')['href']}"
views = result.select_one('.mc_vtvc_meta_row:nth-child(1) span:nth-child(1)').text
date = result.select_one('.mc_vtvc_meta_row:nth-child(1) span+ span').text
video_platform = result.select_one('.mc_vtvc_meta_row+ .mc_vtvc_meta_row span:nth-child(1)').text
channel_name = result.select_one('.mc_vtvc_meta_row_channel').text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment