I am trying to get names and messages from yt live chat.
Here is the code:
import requests
from bs4 import BeautifulSoup
from selenium import webdriver
url ='https://www.youtube.com/live_chat?is_popout=1&v=EEIk7gwjgIM'
browser = webdriver.Firefox()
browser.get(url)
r = requests.get(url)
soup = BeautifulSoup(r.content,"html.parser")
contents =soup.find("yt-live-chat-text-message-renderer")
for content in contents:
author = content.find("span",{"id":"author-name"}).text
message_content = content.find("span",{"id":"message"}).text
print(author+message_content)
It gives me this error:
TypeError: 'NoneType' object is not iterable
How can i solve that?