I am trying to collect the chat setting (follower-only-chat / all) in streams, using python.
So far, I tried collecting the data (1) using Twitch Python, which is based on Twitch API; however, after looking into API document I do not think there is any way for me to collect the data using API.
I also tried (2) using requests and BeautifulSoup, but the chat setting won’t appear in the output.
Lastly I tried (3) selenium and use find_elements_by_xpath to extract the chat setting and it did not work – maybe I got it incorrect.
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.common.exceptions import TimeoutException
html = None
url = ‘https://www.twitch.tv/’+acc_streams['channel_name’]
selector = ‘#dataTarget > div’
delay = 15 # seconds
browser = webdriver.Chrome()
# wait for button to be enabled
button = browser.find_element_by_id(‘getData’)
# wait for data to be loaded WebDriverWait(browser, delay).until( EC.presence_of_element_located((By.CSS_SELECTOR, selector)) ) content = driver.find_elements_by_xpath('/html/body/div/div/div/div/div/div/div/div/div/div/div/div/section/div/div/div/div/button/p') print(content)
So I was wondering if there is any other ways to collect the stream chat setting.