斗鱼直播平台自动钓鱼软件-源码
看着几千的鱼饵没用,也不知道钓鱼是干什么的,所以用Python写了一个,道具ID没有全部收集,可以凑合用,结果如下:
import requests import time import urllib3 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) def safe_print(content): try: print(str(content)) except UnicodeEncodeError: print(str(content).encode('utf-8', errors='replace').decode('utf-8')) # 鱼的ID与名称映射 fish_names = { 29: '鲸鲨', 6: '大白鲨', 38: '双头鲨', 28: '锦鲤', 39: '皇带鱼', 40: '帝王蟹', 27: '大王乌贼', 26: '鮟鱇鱼', 5: '翻车鱼', 25: '苏眉鱼', 35: '巨骨舌鱼', 36: '食人鱼', 37: '真鲷', 20: '金枪鱼', 23: '剑鱼', 21: '石斑鱼', 33: '狮子鱼', 34: '蓝倒吊', 22: '河豚', 24: '小丑鱼', 17: '电鳗', 15: '比目鱼', 18: '罗非鱼', 32: '鲍鱼', 4: '水母', 16: '孔雀鱼', 19: '章鱼', 31: '寄居蟹', 8: '海星', 12: '草鱼', 14: '金鱼', 9: '海马', 10: '海螺', 11: '小龙虾', 13: '泥鳅' } # URL 和数据 fish_url = 'https://www.douyu.com/japi/revenuenc/web/actfans/fishing/fishing' reel_url = 'https://www.douyu.com/japi/revenuenc/web/actfans/fishing/reelIn' ctn = ''#Cookie里的acf_ccn值 rid = ''#房间号 #修改下面的Cookie headers = { 'User-Agent': 'Mozilla/5.0', 'Content-Type': 'application/x-www-form-urlencoded', 'Referer': 'https://www.douyu.com/topic/hlyy2024', 'Origin': 'https://www.douyu.com', 'Cookie': ''#设置自己的Cookie } while True: try: fish_data = { 'ctn': ctn, 'rid': rid, 'baitId': '1', 'ver': '1.1' } reel_data = { 'ctn': ctn, 'rid': rid } # 发起钓鱼请求 response = requests.post(fish_url, data=fish_data, headers=headers, timeout=10, verify=False) res_json = response.json() if res_json.get('msg', '').lower() == 'success': safe_print("钓鱼成功,请等待60秒。") # 获取鱼饵数量 baits = res_json.get('data', {}).get('baits', []) total_bait_cnt = sum(bait.get('cnt', 0) for bait in baits) #safe_print(f"当前鱼饵总数:{total_bait_cnt}") if total_bait_cnt < 50: safe_print("鱼饵不足,停止钓鱼") safe_print(f"当前鱼饵总数:{total_bait_cnt}") break # 等待鱼上钩 time.sleep(65) # 收杆 reel_response = requests.post(reel_url, data=reel_data, headers=headers, timeout=10, verify=False) reel_json = reel_response.json() #safe_print("收杆请求响应:") #safe_print(reel_json) if reel_json.get('msg', '').lower() == 'success': fish_info = reel_json.get('data', {}).get('fish', {}) wei = fish_info.get('wei', 0) fish_id = fish_info.get('id', 0) fish_name = fish_names.get(fish_id, '未知道具') # 奖励处理 awards = reel_json.get('data', {}).get('awards', []) award_text = "" if awards: award_list = [f"{award.get('awardName', '未知奖励')} x {award.get('awardNum', 0)}" for award in awards] award_text = ",额外奖励" + ",".join(award_list) safe_print(f"******收杆成功,重量为{wei}斤,品种为{fish_name}{award_text}。******") time.sleep(2) else: safe_print("收杆失败,尝试重新开始") time.sleep(5) else: safe_print("钓鱼失败,尝试重新开始") safe_print(res_json) time.sleep(5) except Exception as e: safe_print("请求失败:" + str(e)) safe_print("钓鱼请求数据为:" + '&'.join(f"{k}={v}" for k, v in fish_data.items())) time.sleep(10)