十行代码爬抖音直播
from selenium import webdriver
from selenium.webdriver.common.by import By
chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option('excludeSwitches', ['enable-automation'])
chrome_options.add_argument('--disable-blink-features=AutomationControlled')
browser = webdriver.Chrome(options = chrome_options)
url = 'https://live.douyin.com/63796022481'
browser.get(url)
while True:
text = browser.find_elements(By.XPATH, '//*[@id="island_4a5da"]/div/div[2]/div/div/div[1]/div/div[1]/div/div[1]/div')[-1].text
if not text:
print(text)
break
browser.quit()