1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
|
import requests import base64 import re import json
from pprint import pprint from typing import List from parsel.selector import Selector from fontTools.ttLib import TTFont
pts2num = { (44,): "3", (37,): "5", (32, 13, 12): "8", (10,): "1", (11, 4): "4", (30,): "2", (29, 12): "9", (13, 13): "0", (28, 13): "6", (7,): "7", }
hero_names = [ "极镀ギ紬荕", "爷灬霸气傀儡", "梦战苍穹", "傲世哥", "мaη肆風聲", "一刀メ隔世", "横刀メ绝杀", "Q不死你R死你", "魔帝殤邪", "封刀不再战", "倾城孤狼", "戎马江湖", "狂得像风", "影之哀伤", "謸氕づ独尊", "傲视狂杀", "追风之梦", "枭雄在世", "傲视之巅", "黑夜刺客", "占你心为王", "爷来取你狗命", "御风踏血", "凫矢暮城", "孤影メ残刀", "野区霸王", "噬血啸月", "风逝无迹", "帅的睡不着", "血色杀戮者", "冷视天下", "帅出新高度", "風狆瑬蒗", "灵魂禁锢", "ヤ地狱篮枫ゞ", "溅血メ破天", "剑尊メ杀戮", "塞外う飛龍", "哥‘K纯帅", "逆風祈雨", "恣意踏江山", "望断、天涯路", "地獄惡灵", "疯狂メ孽杀", "寂月灭影", "骚年霸称帝王", "狂杀メ无赦", "死灵的哀伤", "撩妹界扛把子", "霸刀☆藐视天下", "潇洒又能打", "狂卩龙灬巅丷峰", "羁旅天涯.", "南宫沐风", "风恋绝尘", "剑下孤魂", "一蓑烟雨", "领域★倾战", "威龙丶断魂神狙", "辉煌战绩", "屎来运赚", "伱、Bu够档次", "九音引魂箫", "骨子里的傲气", "霸海断长空", "没枪也很狂", "死魂★之灵", ]
yuanrenxue_headers = { "User-Agent": "yuanrenxue.project", "sessionid": "e5pcc3skngi5s3kes0mwg4tpctykb8sb", }
def main(): hero_lp = {} for page in range(1, 6): ttf_url = f"http://match.yuanrenxue.com/api/match/7?page={page}" res = requests.get(ttf_url, headers=yuanrenxue_headers) json_data = json.loads(res.text) zt_data: List = json_data["data"] ttf_data: str = json_data["woff"]
b = base64.b64decode(ttf_data) woff_name = "第七关.woff" xml_name = "第七关.xml" with open(woff_name, "wb") as f: f.write(b)
fonts = TTFont(woff_name) fonts.saveXML(xml_name)
with open(xml_name, "r") as f: xml_text = f.read()
dom = Selector(text=xml_text) uni2num = {} for ttg in dom.xpath("//glyf/ttglyph")[1:]: uni = ttg.xpath("./@name").re_first("uni(.+)")
contours = ttg.xpath("./contour") cont_pts = [] for cont in contours: pts = cont.xpath("./pt").getall() cont_pts.append(len(pts)) real_num = pts2num.get(tuple(cont_pts)) uni2num[uni] = real_num
n_i = 1 for data in zt_data: s = data["value"] l = re.sub(r"&#x", "", s) t = [uni2num[n] for n in l.strip().split(" ")] count = int("".join(t)) hero_lp[hero_names[(page - 1) * 10 + n_i]] = count n_i += 1
pprint(hero_lp) d = sorted(hero_lp.items(), key=lambda x: x[1]) print(f"胜点数最多的召唤师为:{d[-1][0]}")
if __name__ == "__main__": main()
|