Brief introduction: it is supposed to check whether the user is live on Instagram or not.
When I run it, it always says user is not live. No matter if the user is live or not live.
import requests
from bs4 import BeautifulSoup
# username
username = '...'
# Construct the profile URL
url = f"https://www.instagram.com/{username}/"
# Retrieve the HTML page of the profile
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
# Find the live indicator element
live_indicator = soup.find('div', class_='hzyi9')
# Check if the user is live
if live_indicator:
print(f"{username} is currently live!")
else:
print(f"{username} is not live.")
New contributor
mik is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.