You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Curl seems to be blocked however the closet workaround i found to getting the data is to use selenium
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from bs4 import BeautifulSoup
import json
# Configure Selenium to use headless Firefox
options = Options()
options.headless = True
driver = webdriver.Firefox(options=options)
# Define the URL to fetch data from
url = "https://kick.com/api/v2/channels/{some_username}"
# Open the URL
driver.get(url)
# Get the page source
page_source = driver.page_source
# Close the driver
driver.quit()
# Parse the page source using BeautifulSoup
soup = BeautifulSoup(page_source, 'html.parser')
# Assuming the JSON data is directly within the body tag
body_text = soup.find('body').get_text()
# Try to parse the text as JSON
try:
data = json.loads(body_text)
# Access channel attributes
print("Channel ID:", data["id"])
print("Username:", data["user"]["username"])
print("Bio:", data["user"]["bio"])
print("Avatar URL:", data["user"]["profile_pic"])
print("Followers:", data["followers_count"])
print("Playback URL:", data["playback_url"])
try:
print("Current live viewers:", data["livestream"]["viewer_count"])
except KeyError:
print("Channel is not live")
except json.JSONDecodeError as e:
print(f"Failed to parse JSON response: {e}")
print("Body text:", body_text)
While this isnt perfect it does seem to get the job done in getting the data. Im sure someone with more experince then me can make a better fix
The text was updated successfully, but these errors were encountered:
When running the sample code
channel value is equal to None.
Curl seems to be blocked however the closet workaround i found to getting the data is to use selenium
While this isnt perfect it does seem to get the job done in getting the data. Im sure someone with more experince then me can make a better fix
The text was updated successfully, but these errors were encountered: