-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmhxy_travel.py
39 lines (33 loc) · 1.28 KB
/
mhxy_travel.py
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
# -*- encoding: utf-8 -*-
'''
@File: mhxy_travel.py
@Descripttion: 梦幻西游转服查询
@Date: 2022-03-13 09:32:58
@Author: xianxiaoyin
'''
import requests
def getHtml(url) -> dict:
html = requests.get(url)
startIndex = html.text.index("=")
return (eval(html.text[startIndex+1:]))
def main():
while True:
searchName = input("你正在使用的是【可转入服务器查询程序】请输入你要查询的服务器:[输入q/Q退出]")
if searchName == "q" or searchName == "Q":
break
urlTravel = "http://xyq.163.com/2011/zhuanyi/js/travel_list.js"
urlServer = "http://xyq.163.com/2011/zhuanyi/js/server_list.js"
travelDict = getHtml(urlTravel)
serverDict = getHtml(urlServer)
tag = True
for k, v in travelDict.items():
if searchName in v:
tag = False
vList = [{serverDict[i]: i}for i in v]
print("转出服务器--->{}".format(k))
for j in vList:
print(" 转入服务器--->{0}:{1}".format(list(j.keys())[0], list(j.values())[0]))
if tag:
print("你查询的服务器,不能够转出到任何其他服务器中!")
if __name__ == "__main__":
main()