Ejemplo n.º 1
0
def count_base(question, choices):
    print('-- 题目搜索结果包含选项词频计数法 --')
    # 搜索答案
    req = requests.get(url='http://www.baidu.com/s', params={'wd': question})
    counts = []
    print('\nQuestion: ' + question)

    for i in range(len(choices)):
        counts.append(req.text.count(choices[i]))

    #输出答案
    counts = list(map(int, counts))
    index_max = counts.index(max(counts))
    index_min = counts.index(min(counts))
    print(counts)
    if counts == [0, 0, 0, 0]:
        print("这题不会...")
        time.sleep(3)

    elif '不是' in question or '不属于' in question or '不包含' in question or '不包括' in question:
        print('**请注意此题可能为否定题,否定题选第一个选项**')
        print("答案可能是:{0} 或者 {1}".format(choices[index_min],
                                        choices[index_max]))
        index_max = counts.index(min(counts))  # 取第一个选项
    else:
        print("答案是:{0}".format(choices[index_max]))
    #print(index_max)
    while not os.path.exists('question-zh.hortor.net/question/bat/choose'):
        time.sleep(random.uniform(0.5, 2))  # 随机答题,避免被发现
        # time.sleep(0.5)
        adbshell.tap('option' + str(index_max))
Ejemplo n.º 2
0
def count_base(question,choices):
    print('\n-- 题目搜索结果包含选项词频计数法 --\n')
    # 搜索答案
    req = requests.get(url='http://www.baidu.com/s', params={'wd':question})
    counts = []
    print('Question: '+question)

    for i in range(len(choices)):
        counts.append(req.text.count(choices[i]))
	
	#输出答案
    counts = list(map(int, counts))
    index_max = counts.index(max(counts))
    index_min = counts.index(min(counts))
    print(counts)
    if counts == [0,0,0,0]:
        print("这题不会...")

    elif '不' in question:
        print('**请注意此题可能为否定题,否定题选第一个选项**')
        print("答案可能是:{0} 或者 {1}".format(choices[index_min],choices[index_max]))
    else:
        print("答案是:{0}".format(choices[index_max]))
    print(index_max)
    while not os.path.exists('question-zh.hortor.net/question/bat/choose'):
        time.sleep(0.5)
        adbshell.tap('option' + str(index_max))
Ejemplo n.º 3
0
	def on_created(self,event):
		global quiz
		if event.src_path.split('/')[-1] == 'findQuiz':
			with open('question-zh.hortor.net/question/bat/findQuiz', encoding='utf-8') as f:
				quiz=read_question(f)
		elif event.src_path.split('/')[-1] == 'choose':
			sql.sql_write(quiz)
		elif event.src_path.split('/')[-1] == 'fightResult':
			print('本局结束')
			time.sleep(3)
			adbshell.back()
			time.sleep(3)
			adbshell.tap('start')
Ejemplo n.º 4
0
	def on_created(self,event):
		global quiz
		if event.src_path.split('/')[-1] == 'findQuiz':
			with open('question.hortor.net/question/bat/findQuiz', encoding='utf-8') as f:
				quiz=read_question(f)
		elif event.src_path.split('/')[-1] == 'choose':
			sql.sql_write(quiz)
		elif event.src_path.split('/')[-1] == 'fightResult':
			print('本局结束')
			time.sleep(3)
			adbshell.back()
			time.sleep(3)
			adbshell.tap('start')
Ejemplo n.º 5
0
def read_question(f):
    time.sleep(1)
    response = json.load(f)
    f.close()
    os.remove('question-zh.hortor.net/question/bat/findQuiz')
    question = response['data']['quiz']
    options = response['data']['options']
    sql_result = sql.sql_match_result('"%s"' % question)
    if sql_result:
        print('\nQuestion: ' + question)
        print('绝对正确答案:%s' % sql_result)
        while not os.path.exists('question-zh.hortor.net/question/bat/choose'):
            time.sleep(0.5)
            adbshell.tap('option' + str(options.index(sql_result)))
    else:
        count_base(question, options)
    return response
Ejemplo n.º 6
0
def read_question(f):
	time.sleep(1)
	response = json.load(f)
	f.close()
	os.remove('question-zh.hortor.net/question/bat/findQuiz')
	question = response['data']['quiz']
	options = response['data']['options']
	sql_result=sql.sql_match_result('"%s"' % question)
	if sql_result:
		print('Question: '+question)
		print('绝对正确答案:%s' % sql_result)
		while not os.path.exists('question-zh.hortor.net/question/bat/choose'):
			time.sleep(0.5)
			adbshell.tap('option' + str(options.index(sql_result)))
	else:
		count_base(question, options)
	return response