Last active
January 21, 2018 01:47
-
-
Save l1905/265a4ec37b978f74957600e12955cbbb to your computer and use it in GitHub Desktop.
头脑王者答题辅助(https://github.com/chxj1992/hortor_cheater, 将作者的listen.py替换即可)
This file contains hidden or 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/fight/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 | |
for i in range(len(options)): | |
option = options[i] | |
count = content.count(option) | |
ctx.log.info('option : %s, count : %s'%(option, count)) | |
options[i] = options[i] + ':'+ str(count) | |
return options |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment