Created
June 20, 2021 05:06
-
-
Save dimitryzub/5b6d803df02688e8e8ce4400e9e97e89 to your computer and use it in GitHub Desktop.
selenium_youtube_get_channel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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