Python破解巴士盘免费下载等待30秒,普通用户无需等待xx秒后,不限速,屏蔽广告。只需要找好资源,复制链接进去就ok了。
成品打包下载链接:https://lanren.lanzous.com/igAxbnxdvdi
#全部源码 import requests, bs4, json, time, re, os from sys import stdout class BaShiPan(): def __init__(self): # 协议头 vip cookies self.V_Cookies = f'UM_distinctid=16e45e3c0040-0e9d7e056215bb-5f4e2917-144000-16e45e3c0052b1; CNZZDATA1278068732=1786585831-1573129385-%7C{int(time.time())}; view_stat=1 ;' self.headers = { 'Connection': 'keep-alive', 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 'Referer': 'http://www.tadaigou.com/file/QUEzNDQyMQ==.html', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.87 Safari/537.36', 'Upgrade-Insecure-Requests': '1', 'Host': 'www.tadaigou.com', 'cookie': self.V_Cookies } self.path = "./down/" try: os.mkdir(self.path) except: pass def get_down_file_info(self, url): ''' 获取文件信息 :return: 返回文件信息字典 ''' file_info = {} # 访问目标页面------------------------------------------ self.res = requests.get(url, headers=self.headers) self.V_Cookies = self.V_Cookies + 'PHPSESSID=' + self.res.cookies.get_dict()['PHPSESSID'] self.headers['cookie'] = self.V_Cookies self.headers['Referer'] = url # 获取信息 ''.replace file_info['id'] = self.get_str_center(self.res.text, 'add_ref(', ');')[-1][-1].replace(')', '').replace('(', '') file_info['name'] = self.get_str_center(self.res.text, '<span class="down_one_lf_tl" style="float:left;margin-left:150px">', ' ')[-1] return file_info def get_str_center(self, text, head_text, tail_text): ''' 返回指定头尾中间的文本内容 :param text: 目标text :param head_text: 头 :param tail_text: 尾 :return: 返回内容的列表 ''' t_re = f'{head_text}(.*){tail_text}' return re.findall(t_re, text) def get_downfile_href_host(self, file_info): ''' 获取下载文件所需的地址和文件头 :param file_info: :return: ''' data = {'action': 'load_down_addr1', 'file_id': file_info['id'], 'vipd': 0 } self.res = requests.post('http://www.tadaigou.com/ajax.php', headers=self.headers, data=data) href = self.get_str_center(self.res.text, 'true|<a href="', '" onclick')[-1] host = self.get_str_center(self.res.text, 'http://', '/dl.php')[-1] return href, host def down_file(self, href, host, name): # 下载文件头 headers = { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 'Referer': 'http://www.tadaigou.com', 'Host': host } file_to_save = self.path + name with open(file_to_save, 'wb') as fw: with requests.get(href, headers=headers) as r: # 此时响应头被下载 print('-' * 30) print('下载文件基本信息:') print("文件名称:", name) print("文件类型:", r.headers["Content-Type"]) filesize = r.headers["Content-Length"] print("文件大小:", filesize, "bytes") print("下载地址:", href) print("保存路径:", file_to_save) print("开始下载") # 计算大小 chunk_size = 128 times = int(filesize) // chunk_size show = 1 / times show2 = 1 / times start = 1 for chunk in r.iter_content(chunk_size): fw.write(chunk) if start <= times: stdout.write(f"下载进度: {show:.2%}r") start += 1 show += show2 else: stdout.write("下载进度: 100%") print("n文件名称:", name,"下载完成!") print('-' * 30) if __name__ == '__main__': print('只能下单个小文件,类似百度转存的那种!') while True: key=input('请输入巴士盘的文件地址(输入e退出):') if key=='e': break elif key.find('www.tadaigou.com')!=-1: try: bspan = BaShiPan() info = bspan.get_down_file_info(key) href, host = bspan.get_downfile_href_host(info) bspan.down_file(href, host, info['name']) except: print('发生错误请重试!只能下小文件,百度转存的那种!') else: print('链接中并不是[url]www.tadaigou.com[/url]的,请看清楚')
相关专题
- Python多线程截图工具 [2024-09-10]
- 密码强度检测Python源代码 [2023-06-06]
- 批量转存百度网盘分享资源Python脚本 [2022-09-29]
- Python一键安装卸载工具V1.0 [2022-07-21]
- Python+HTML随机点名抽奖源码模板 [2021-11-01]