If it work with requests_htm then it's okay.
I have only tested requests_htm(problem not updated regularly Github Repo) briefly,can also use Selenuim and load browser with
requests_htm use pyppeteer which is default
Some time is useful the see browser before go headless like see if push button or enter into field,
then Selenium can be better choice.
I have only tested requests_htm(problem not updated regularly Github Repo) briefly,can also use Selenuim and load browser with
--headless
option.requests_htm use pyppeteer which is default
headless
.Some time is useful the see browser before go headless like see if push button or enter into field,
then Selenium can be better choice.
from selenium import webdriver from selenium.webdriver.chrome.options import Options #--| 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/channel/UCwTrHPEglCkDz54iSg9ss9Q/videos" browser.get(url) title = browser.find_elements_by_css_selector('#text-container')[0] print(title.text)
Output:kanalgratisdotse
The fasted way is using the YouTube API.import requests channel_id = 'UCwTrHPEglCkDz54iSg9ss9Q' api_key = 'xxxxxxxxxxxxxxxxxxx' url = f'https://www.googleapis.com/youtube/v3/channels?id={channel_id}&part=snippet&key={api_key}' response = requests.get(url).json() print(response['items'][0]['snippet']['title'])
Output:kanalgratisdotse