from getpass import getpass import requests from html.parser import HTMLParser from html.entities import name2codepoint class episodeParser(HTMLParser): inScript = False code = "" url = "" token = "" def handle_starttag(self, tag, attrs): if tag == 'script': self.inScript = True if tag == 'input' and len(attrs) > 2: if attrs[2][1] == 'proxerToken': self.token = attrs[1][1] def handle_data(self, data): if self.inScript: lines = data.replace('\\n','').split(';') streams = lines[0][lines[0].index('['):] streams = streams.split('}') print(streams[0]) typeIndex = streams[0].index('type') + 7 if streams[0][typeIndex:typeIndex + 13] == 'proxer-stream': print('proxer-steram') codeStart = streams[0].index('code') + 7 code = streams[0][codeStart:] code = code[:code.index('"')] self.code = code print(code) urlStart = streams[0].index('replace') + 10 url = streams[0][urlStart:streams[0].index('.html') + 5] self.url = url.replace("\\\\","") print("url: " + url) def handle_endtag(self, tag): if tag == 'script' and self.inScript: self.inScript = False