Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import requests
- from bs4 import BeautifulSoup
- baseURL = 'https://www.twitch.tv/'
- headers = headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)',
- 'Accept-Encoding': 'gzip, deflate, br'}
- IDLIST = ["examplename","example2"]
- streamlist = []
- for x in IDLIST:
- response = requests.get(baseURL+x, headers=headers)
- if(response.status_code != 200):
- print("error:" + str(response.status_code))
- data = BeautifulSoup(response.text, 'html.parser')
- #there's a json that runs if they are live
- live_indicator = data.findAll('script', type='application/ld+json')
- if(len(live_indicator) == 0):
- print(x + " is not live")
- else:
- print(x + " is live!")
- data = str(live_indicator[0])[60:].split(",")
- print("desc: " + data[1].split(":")[1]) #comment this out if wanted, desc offers a peak into their mind
- #1 = desc, 2 = embed URL, 3= name, 4=thumbnails
- streamlist.append(baseURL+x)
- time.sleep(0.5)
- #wait before each request
- for x in streamlist:
- print(x)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement