This repository has been archived by the owner on May 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
getQuestionAnswer.py
64 lines (43 loc) · 1.79 KB
/
getQuestionAnswer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# -*- coding: utf-8 -*-
# @Author : Skye
# @Time : 2018/1/8 20:38
# @desc : 答题闯关辅助,截屏 ,OCR 识别,百度搜索
import wda
from PIL import Image
from common import ocr, methods
from threading import Thread
import os
# c = wda.Client()
isTrue = True
while isTrue:
# 截图
# c.screenshot('screenshot.png')
# os.system("screencapture -R\"20,150,310,310\" ./screenshot.png")
# 西瓜视频
# os.system("screencapture -R\"20,150,310,100\" ./question_screenshot.png")
# os.system("screencapture -R\"20,250,310,200\" ./choices_screenshot.png")
os.system("screencapture -R\"20,190,310,100\" ./question_screenshot.png")
os.system("screencapture -R\"20,320,310,180\" ./choices_screenshot.png")
question_img = Image.open("./question_screenshot.png")
choices_img = Image.open("./choices_screenshot.png")
# 文字识别
question, choices = ocr.ocr_img(question_img, choices_img)
print("问题%s \n选择:%s"%(question, choices))
# 用不同方法输出结果,取消某个方法在前面加上#
# 打开浏览器方法搜索问题
# methods.run_algorithm(0, question, choices)
# # 将问题与选项一起搜索方法,并获取搜索到的结果数目
# methods.run_algorithm(1, question, choices)
# # 用选项在问题页面中计数出现词频方法
# methods.run_algorithm(2, question, choices)
Thread(methods.run_algorithm(0, question, choices)).start()
Thread(methods.run_algorithm(1, question, choices)).start()
Thread(methods.run_algorithm(2, question, choices)).start()
# m1.start()
# m2.start()
# m3.start()
go = input('输入回车继续运行,输入 n 回车结束运行: ')
if go == 'n':
break
print('------------------------')
# isTrue = False