|
| 1 | +import requests |
| 2 | +import urllib |
| 3 | +import hashlib |
| 4 | +import sys |
| 5 | +import json |
| 6 | +import console |
| 7 | + |
| 8 | +url = "http://www.xhup.club/Xhup/Search/searchCode" |
| 9 | + |
| 10 | +search_word = console.input_alert(u'想查哪些字的编码?') |
| 11 | +if not search_word: |
| 12 | + print('No text input found.') |
| 13 | + sys.exit(0) |
| 14 | + |
| 15 | +key_xhup = 'fjc_xhup' |
| 16 | + |
| 17 | +search_word_url = urllib.parse.quote(search_word) |
| 18 | + |
| 19 | +ret = key_xhup + search_word |
| 20 | +sign = hashlib.md5((ret).encode('utf-8')).hexdigest() |
| 21 | + |
| 22 | +payload = 'search_word={}&sign={}'.format(search_word_url, sign) |
| 23 | +headers = { |
| 24 | + 'Origin': 'http://react.xhup.club', |
| 25 | + 'Referer': 'http://react.xhup.club/search', |
| 26 | + 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Safari/537.36', |
| 27 | + 'Host': 'www.xhup.club', |
| 28 | + 'Content-Type': 'application/x-www-form-urlencoded', |
| 29 | + 'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8', |
| 30 | + 'Accept': 'application/json, text/plain, */*' |
| 31 | +} |
| 32 | + |
| 33 | +response = requests.request("POST", url, headers=headers, data = payload) |
| 34 | + |
| 35 | +if response.status_code == 200: |
| 36 | + data = response.json() |
| 37 | + if data['msg'] == 'success': |
| 38 | + list_dz = data['list_dz'] |
| 39 | + # print(json.dumps(list_dz, ensure_ascii=False, indent=2)) |
| 40 | + for x in list_dz: |
| 41 | + print(x[0]) |
| 42 | + print('● 拆分:{}'.format(x[1])) |
| 43 | + print('● 首末:{} {}'.format(x[2], x[3])) |
| 44 | + print('● 形码:{} {}'.format(x[4], x[5])) |
| 45 | + print('--------------------') |
| 46 | + else: |
| 47 | + print(response.json()) |
| 48 | +else: |
| 49 | + print('请求异常') |
| 50 | + print(response.json()) |
| 51 | + sys.exit(1) |
| 52 | + |
0 commit comments