Advertisement
Guest User

heehahahonk

a guest
May 3rd, 2024
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.06 KB | None | 0 0
  1. import time
  2.  
  3. import requests
  4. from bs4 import BeautifulSoup
  5. baseURL = 'https://www.twitch.tv/'
  6. headers = headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)',
  7. 'Accept-Encoding': 'gzip, deflate, br'}
  8. IDLIST = ["examplename","example2"]
  9. streamlist = []
  10. for x in IDLIST:
  11.     response = requests.get(baseURL+x, headers=headers)
  12.     if(response.status_code != 200):
  13.         print("error:" + str(response.status_code))
  14.     data =  BeautifulSoup(response.text, 'html.parser')
  15.     #there's a json that runs if they are live
  16.     live_indicator = data.findAll('script', type='application/ld+json')
  17.     if(len(live_indicator) == 0):
  18.         print(x + " is not live")
  19.     else:
  20.         print(x + " is live!")
  21.         data = str(live_indicator[0])[60:].split(",")
  22.         print("desc: " + data[1].split(":")[1]) #comment this out if wanted, desc offers a peak into their mind
  23.         #1 = desc, 2 = embed URL, 3= name, 4=thumbnails
  24.         streamlist.append(baseURL+x)
  25.     time.sleep(0.5)
  26.     #wait before each request
  27. for x in streamlist:
  28.     print(x)
  29.  
  30.  
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement