Skip to content

Instantly share code, notes, and snippets.

@l1905
Last active January 21, 2018 01:47
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save l1905/265a4ec37b978f74957600e12955cbbb to your computer and use it in GitHub Desktop.
Save l1905/265a4ec37b978f74957600e12955cbbb to your computer and use it in GitHub Desktop.
头脑王者答题辅助(https://github.com/chxj1992/hortor_cheater, 将作者的listen.py替换即可)
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