def get_site_swf(): print('Downloading the page %s' % PAGE_URL) urlh = compat_urllib_request.urlopen(PAGE_URL) webpage = urlh.read().decode('utf-8') urlh.close() mobj = re.search( r'data-flashplayerparam-flashurl="(http://[^"]+.swf)"', webpage) swf_url = mobj.group(1) print('SWF URL is %s' % swf_url) return swf_url
def get_swf(target_site): swf_url = target_site.get_site_swf() parts = compat_urlparse.urlparse(swf_url) swf_path = full_path(os.path.basename(parts.path)) urlh = compat_urllib_request.urlopen(swf_url) with open(swf_path, 'wb') as f: f.write(urlh.read()) if hasattr(target_site, 'decrypt_swf'): old_swf_path = swf_path swf_path = os.path.splitext(swf_path)[0] + '_decrypted.swf' decrypted_swf = target_site.decrypt_swf(read_file(old_swf_path)) write_file(swf_path, decrypted_swf) return swf_path, swf_url
def get_swf(target_site): swf_url = target_site.get_site_swf() parts = compat_urlparse.urlparse(swf_url) swf_path = full_path(os.path.basename(parts.path)) urlh = compat_urllib_request.urlopen(swf_url) with open(swf_path, 'wb') as f: f.write(urlh.read()) if hasattr(target_site, 'decrypt_swf'): old_swf_path = swf_path swf_path = os.path.splitext(swf_path)[0] + '_decrypted.swf' decrypted_swf = target_site.decrypt_swf(read_file(old_swf_path)) write_file(swf_path, decrypted_swf) return swf_path, swf_url
def get_site_swf(): HOME_URL = 'http://www.douyutv.com/' print('Downloading the page %s' % HOME_URL) urlh = compat_urllib_request.urlopen(HOME_URL) webpage = b'' while True: webpage += urlh.read(1024) mobj = re.search(br'"swf_ver":"([^"]+)"', webpage) if mobj: break swf_ver = mobj.group(1).decode('utf-8') swf_url = 'http://staticlive.douyutv.com/common/simplayer/core.swf?' + swf_ver print('SWF URL is %s' % swf_url) return swf_url
def get_site_swf(): HOME_URL = 'http://www.douyutv.com/' print('Downloading the page %s' % HOME_URL) urlh = compat_urllib_request.urlopen(HOME_URL) webpage = b'' while True: webpage += urlh.read(1024) mobj = re.search(br'"swf_ver":"([^"]+)"', webpage) if mobj: break swf_ver = mobj.group(1).decode('utf-8') swf_url = 'http://staticlive.douyutv.com/common/simplayer/core.swf?' + swf_ver print('SWF URL is %s' % swf_url) return swf_url