Skip to content

Instantly share code, notes, and snippets.

@dimitryzub
Created June 20, 2021 05:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dimitryzub/5b6d803df02688e8e8ce4400e9e97e89 to your computer and use it in GitHub Desktop.
Save dimitryzub/5b6d803df02688e8e8ce4400e9e97e89 to your computer and use it in GitHub Desktop.
selenium_youtube_get_channel
from selenium import webdriver
def get_channel_results():
driver = webdriver.Chrome()
driver.get('https://www.youtube.com/results?search_query=mojang')
title = driver.find_element_by_css_selector('#info #text').text
link = driver.find_element_by_css_selector('#main-link').get_attribute('href')
subs = driver.find_element_by_css_selector('#subscribers').text
video_count = driver.find_element_by_css_selector('#video-count').text
desc = driver.find_element_by_css_selector('#description').text
print(f'{title}\n{link}\n{subs}\n{video_count}\n{desc}')
get_channel_results()
# output:
'''
Minecraft
https://www.youtube.com/user/TeamMojang
7.4M subscribers
542 videos
This is the official YouTube channel of Minecraft. We tell stories about the Minecraft Universe. ESRB Rating: Everyone 10+ with ...
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment