头脑王者答题辅助(https://github.com/chxj1992/hortor_cheater, 将作者的listen.py替换即可)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import json | |
from mitmproxy import ctx | |
from urllib.parse import quote | |
import string | |
import requests | |
def response(flow): | |
path = flow.request.path | |
if path == '/question/bat/findQuiz': | |
content = flow.response.content | |
data = json.loads(content) | |
question = data['data']['quiz'] | |
options = data['data']['options'] | |
ctx.log.info('question : %s, options : %s'%(question, options)) | |
options = ask(question, options) | |
data['data']['options'] = options | |
flow.response.text = json.dumps(data) | |
def ask(question, options): | |
url = quote('http://www.baidu.com/s?wd=' + question, safe = string.printable) | |
content = requests.get(url).text | |
c=[0,0,0,0] | |
for i in range(len(options)): | |
option = options[i] | |
count = content.count(option) | |
c[i]=count | |
ctx.log.info('option : %s, count : %s'%(option, count)) | |
options[i] = options[i] + ':'+ str(count) | |
options[c.index(max(c))] = '--> '+options[c.index(max(c))] | |
return options |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment