Dec-05-2021, 10:00 PM
Use Code Tags
You most download version 96,97 is still in beta.
Here a example setup.
You most download version 96,97 is still in beta.
chromedriver.exe
most be in Environment Variables Path if unsure place it in C:\Windows\chromedriver.exeHere a example setup.
from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.keys import Keys from bs4 import BeautifulSoup import time #--| Setup options = Options() #options.add_argument("--headless") #options.add_argument("--window-size=1980,1020") browser = webdriver.Chrome(executable_path=r'C:\cmder\bin\chromedriver.exe', options=options) #--| Parse or automation url = "https://www.youtube.com/results?search_query=python" browser.get(url) # Example of using both to parse time.sleep(2) soup = BeautifulSoup(browser.page_source, 'lxml') use_bs4 = title = soup.find('a', id="video-title") print(use_bs4.text.strip()) print('-' * 25) use_sel = browser.find_elements_by_css_selector('#video-title > yt-formatted-string') print(use_sel[0].text)
Output:Learn Python - Full Course for Beginners [Tutorial]
-------------------------
Learn Python - Full Course for Beginners [Tutorial]