zoukankan      html  css  js  c++  java
  • 《明日方舟》Python版公开招募工具

    工具介绍

    根据输入的标签,快速找出能够招募4星,5星干员的标签组合,比如刷出了 重装 | 男 | 支援 |术师 | 先锋 五个标签,输入效果如下:

    注意:不支持高级干员和资深高级干员标签

    使用环境

    1. 安装python3
    2. 安装模块:requests、BeautifulSoup4

    代码

    import requests, sys, bs4, itertools
    
    all_tags = set()
    
    def parseData(data):
        worker_infos = []
        bsObj = bs4.BeautifulSoup(data, "html.parser")
        details = bsObj.findAll("div",{"class": "contentDetail"})
        for detail in details:
            if u"公开招募" not in detail.attrs["data-param1"]:
                continue
            name = detail.find("a").attrs["title"].strip()
            profes = detail.attrs["data-param1"].split(",")[0].strip()
            sex = detail.attrs["data-param1"].split(",")[1].strip()
            star = detail.attrs["data-param2"].strip()
            tags = set()
            for tag in detail.findAll("span", {"class": "tagText"}):
                tags.add(tag.getText().strip())
                all_tags.add(tag.getText().strip())
            tags.add(profes)
            tags.add(sex)
            all_tags.add(profes)
            all_tags.add(sex)
            info = [tags, star, "%s(%s星)" % (name, star)]
            worker_infos.append(info)
        return worker_infos
    
    
    def printTip():
        tip = "
    可选标签:
    "
        count = 0
        for tag in all_tags:
            tip = tip + tag + " | "
            count += 1
            if count % 9 == 0:
                tip += "
    "
        tip += "
    "
        print(tip)
    
    
    def checkTags(tags):
        for tag in tags:
            if tag not in all_tags:
                print("
    " + tag + " 为无效标签")
    
    
    def getCombs(tags):
        combs = []
        for i in range(len(tags)):
            for iter in itertools.combinations(tags, i + 1):
                combs.append(set(iter))
        return combs
    
    
    def getWorkers(tags, worker_infos):
        ret = []
        combs = getCombs(tags)
        for comb in combs:
            workers = []
            over4 = True
            for worker in worker_infos:
                if comb <= worker[0]:
                    if int(worker[1]) == 4 or int(worker[1]) == 5:
                        workers.append(worker)
                    elif int(worker[1]) == 3:
                        over4 = False
            if over4 == True and len(workers) > 0:
                ret.append([comb, workers])
        return ret
    
    
    def printWorkers(workers):
        for worker in workers:
            tip = "
    | "
            for tag in worker[0]:
                tip = tip + tag + " | "
            tip += "可以招募以下干员:
    "
            for info in worker[1]:
                tip = tip + info[2] + "
    "
            print(tip)
    
    url = "http://wiki.joyme.com/arknights/公开招募工具"
    res = requests.get(url)
    
    if res.status_code == requests.codes.ok:
        infos = parseData(res.text)
        printTip()
            
        while True:
            input_tags = input("请输入标签,使用空格隔开:
    ").split()
            checkTags(input_tags)
            
            workers = getWorkers(input_tags, infos)
            if len(workers) > 0:
                printWorkers(workers)
            else:
                print("不能招聘高星干员")
            print("--------------------------------------
    ")
    else:
        print("获取数据失败")
    

    数据来源

    公开招募工具

  • 相关阅读:
    Visual Studio的调试技巧
    释放linux的buff/cache
    Markdown画各种图表
    通过 SSH 转发TCP连接数据
    Linux之间用SSH传输文件 一行命令实现
    C# 使用OpenCV在一张图片里寻找人脸
    C# AOP 面向切面编程之 调用拦截
    ES5中新增的Array方法详细说明
    使用json数据动态创建表格2(多次绘制第一次简化 var tr=tbody.insertRow();)
    动态创建表格1
  • 原文地址:https://www.cnblogs.com/zhouzl/p/11015634.html
Copyright © 2011-2022 走看看