《明日方舟》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 = "\n可選標簽:\n"
    count = 0
    for tag in all_tags:
        tip = tip + tag + " | "
        count += 1
        if count % 9 == 0:
            tip += "\n"
    tip += "\n"
    print(tip)


def checkTags(tags):
    for tag in tags:
        if tag not in all_tags:
            print("\n" + 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 = "\n| "
        for tag in worker[0]:
            tip = tip + tag + " | "
        tip += "可以招募以下干員:\n"
        for info in worker[1]:
            tip = tip + info[2] + "\n"
        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("請輸入標簽,使用空格隔開:\n").split()
        checkTags(input_tags)
        
        workers = getWorkers(input_tags, infos)
        if len(workers) > 0:
            printWorkers(workers)
        else:
            print("不能招聘高星干員")
        print("--------------------------------------\n")
else:
    print("獲取數據失敗")

數據來源

公開招募工具


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM