skyexu / topsup Goto Github PK
View Code? Open in Web Editor NEW答题辅助决策:头号英雄等答题类游戏
Home Page: https://www.jianshu.com/p/dc828c4b901d
答题辅助决策:头号英雄等答题类游戏
Home Page: https://www.jianshu.com/p/dc828c4b901d
File "C:\Users\Admin\Desktop\GetQuestionTessAndroid.py", line 9, in
from common import screenshot, ocr, methods
ImportError: cannot import name 'ocr'
找不到ocr?我需要这么做?
我是写c++的 ,如果图像识别用api来做应该更快
浏览器 打开是乱码的
但是控制台不是,求解
question_im = image.crop((120, 360, 1000, 540)) # mi5
choices_im = image.crop((140, 660, 900, 1200))
C:\Users\Administrator\Desktop\TopSup-master\TopSup-master>python GetQuestionTes
sAndroid.py
采用方式 2 获取截图
Traceback (most recent call last):
File "GetQuestionTessAndroid.py", line 20, in
question, choices = ocr.ocr_img(img)
File "C:\Users\Administrator\Desktop\TopSup-master\TopSup-master\common\ocr.py
", line 64, in ocr_img
question = pytesseract.image_to_string(question_im, lang='chi_sim', config=t
essdata_dir_config)
File "C:\python3.6\lib\site-packages\pytesseract\pytesseract.py", line 122, in
image_to_string
config=config)
File "C:\python3.6\lib\site-packages\pytesseract\pytesseract.py", line 46, in
run_tesseract
proc = subprocess.Popen(command, stderr=subprocess.PIPE)
File "C:\python3.6\lib\subprocess.py", line 709, in init
restore_signals, start_new_session)
File "C:\python3.6\lib\subprocess.py", line 997, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] 系统找不到指定的文件。
一个问题 + 一个答案 = 一个搜索窗口(配合chrome插件做, 非答案文件全部隐藏,答案字体放大,加粗)
每次重新运行都要耗时间,一直常驻,按回车或者别的,开始新的一次检测可以么?
还有就是感觉时间都花到截图上面去了,有优化的空间么?
请问token里面应该填什么
(python36) E:\AssisiTool\TopSup-master>GetQuestionTessAndroid.py
閲囩敤鏂瑰紡 2 鑾峰彇鎴浘
Traceback (most recent call last):
File "E:\AssisiTool\TopSup-master\GetQuestionTessAndroid.py", line 20, in
question, choices = ocr.ocr_img(img)
File "E:\AssisiTool\TopSup-master\common\ocr.py", line 64, in ocr_img
question = pytesseract.image_to_string(question_im, lang='chi_sim', config=t
essdata_dir_config)
File "C:\Python27\lib\site-packages\pytesseract\pytesseract.py", line 122, in
image_to_string
config=config)
File "C:\Python27\lib\site-packages\pytesseract\pytesseract.py", line 46, in r
un_tesseract
proc = subprocess.Popen(command, stderr=subprocess.PIPE)
File "C:\Python27\lib\subprocess.py", line 711, in init
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 959, in _execute_child
startupinfo)
WindowsError: [Error 2]
resptext = requests.get('http://htpmsg.jiecaojingxuan.com/msg/current',timeout=5).text
resptext _dict = json.loads(resptext )
pytesseract.pytesseract.tesseract_cmd = 'C:\Program Files (x86)\Tesseract-OCR\tesseract'
tessdata_dir_config = '--tessdata-dir "C:\Program Files (x86)\Tesseract-OCR\tessdata" --psm 6'
希望能出个详细一点的步骤 写写
Windows下链接: 推荐使用安装版,在安装时选择增加中文简体语言包
安装版: https://digi.bib.uni-mannheim.de/tesseract/tesseract-ocr-setup-3.05.01.exe
按照Read.md中的方式安装了tesseract,运行程序时也存在中文语言包找不到的错误
pytesseract.pytesseract.TesseractError: (1, 'Error opening data file C:\Program Files (x86)\Tesseract-OCR\tessdata/chi_sim.traineddata Please make sure the TESSDATA_PREFIX environment variable is set to the parent directory of your "tessdata" directory. Failed loading language 'chi_sim' Tesseract couldn't load any languages! Could not initialize tesseract.')
adb: error: remote object '/sdcard/screenshot.png' does not exist
TopSup-master python3 GetQuestionTessIos.py
Traceback (most recent call last):
File "GetQuestionTessIos.py", line 21, in
question, choices = ocr.ocr_img(img)
NameError: name 'ocr' is not defined
Requirement already satisfied: pillow in d:\anaconda\envs\topsup\lib\site-packages
截图时间间隔怎么确定的
我是锤子M1L,分辨率2K
question = img.crop((160,480,1280, 700)) # 锤子 M1L
choices = img.crop((170, 760, 1330, 1422))
Traceback (most recent call last):
File "GetQuestionTessAndroid.py", line 32, in
m1 = Thread(methods.run_algorithm(0, question, choices))
File "/Users/ext.charles.ma/Desktop/mm/TopSup/common/methods.py", line 74, in run_algorithm
open_webbrowser(question)
File "/Users/ext.charles.ma/Desktop/mm/TopSup/common/methods.py", line 11, in open_webbrowser
webbrowser.open('https://baidu.com/s?wd=' + question)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/webbrowser.py", line 61, in open
if browser.open(url, new, autoraise):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/webbrowser.py", line 636, in open
osapipe.write(script)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 38-39: ordinal not in range(128)
等待浏览器反应太慢了。题目解析完毕10秒就过去了
C:\Users\LHTV\Desktop\TopSup-master>python GetQuestionTessAndroid.py
Traceback (most recent call last):
File "GetQuestionTessAndroid.py", line 9, in
from common import screenshot, ocr, methods
File "C:\Users\LHTV\Desktop\TopSup-master\common\ocr.py", line 8, in
import pytesseract
File "C:\Python27\lib\site-packages\pytesseract_init_.py", line 2, in
from pytesseract import image_to_string
File "C:\Python27\lib\site-packages\pytesseract\pytesseract.py", line 9, in
import Image
File "C:\Python27\lib\site-packages\PIL\Image.py", line 27, in
from . import VERSION, PILLOW_VERSION, _plugins
ValueError: Attempted relative import in non-package
allRight = pytesseract.image_to_string(all, lang='chi_sim', config=tessdata_dir_config)
pattern = re.compile(u'\d*\.([\s\S]*?)\?');
question = pattern.findall(allRight)
pattern2 = re.compile(u'[A-Za-z]\.([\s\S]*?)\n');
answer = pattern2.findall(allRight)
answer = [ x for x in answer if x != '' ]
return question[0], answer
谷歌收索噪音小很多, 准确率是否会提高
Mac 系统 以下 如何配置环境
pytesseract.pytesseract.tesseract_cmd = 'C:\Program Files (x86)\Tesseract-OCR\tesseract'
tessdata_dir_config = '--tessdata-dir "C:\Program Files (x86)\Tesseract-OCR\tessdata" --psm 6'
我也是刚刚接触这个答题的,因为前几天也试了跳一跳,正有这样的想法。结果各位已经都做好了,哈哈哈。
我觉得之后还可以做的,比如对搜索结果内容进行解析,和答案进行比较,自动进行筛选;再比如收集问题的种类,通过NLP来让搜索的方式更好的匹配问题之类的。
加了一个output
def open_webbrowser_count(question,choices):
print('\n -- 题目+选项搜索结果计数法 -- Question:' + question + '\n')
#print('Question: ' + question + '\n')
if '不是' in question:
print('请注意此题为否定题,选计数最少的')
counts = []
for i in range(len(choices)):
# 请求
req = requests.get(url='http://www.baidu.com/s', params={'wd': question + choices[i]})
content = req.text
index = content.find('百度为您找到相关结果约') + 11
content = content[index:]
index = content.find('个')
count = content[:index].replace(',', '')
counts.append(count)
#print(choices[i] + " : " + count)
#print("\033[0;31m{0:^10}:{1:^10}\033[0m".format(choices[i],count))
#print(counts)
output(choices, counts)
def count_base(question,choices):
print('\n -- 题目搜索结果包含选项词频计数法 -- Question:' + question + '\n')
# 请求
req = requests.get(url='http://www.baidu.com/s', params={'wd':question})
content = req.text
#print(content)
counts = []
#print('Question: ' + question + '\n')
if '不是' in question:
print('请注意此题为否定题,选计数最少的')
for i in range(len(choices)):
counts.append(content.count(choices[i]))
#print((choices[i], + " : " + str(counts[i]))
#print("\033[0;31m{0:^10}:{1:^10}\033[0m".format(choices[i], str(counts[i])))
output(choices, counts)
def output(choices, counts):
counts = list(map(int, counts))
#print(choices, counts)
# 最可能的答案
index_max = counts.index(max(counts))
# 最不可能的答案
index_min = counts.index(min(counts))
if index_max == index_min:
print("\033[1;31m此方法失效!\033[0m")
return
for i in range(len(choices)):
if i == index_max:
# 绿色为最可能的答案
print("\033[1;32m{0:^10} {1:^10}\033[0m".format(choices[i], counts[i]))
elif i == index_min:
# 红色为最不可能的答案
print("\033[0;31m{0:^10}{1:^10}\033[0m".format(choices[i], counts[i]))
else:
print("{0:^10} {1:^10}".format(choices[i], counts[i]))
搜索搜索app,http://sa.sogou.com/weball/page/felab/websocket/ws-channel-bwyx 大佬们快分析一下。
不知道这种技术好不好实现呢
Traceback (most recent call last):
File "GetTitleTessIos.py", line 16, in
c.screenshot('screenshot.png')
File "/usr/local/Cellar/python3/3.6.4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wda/init.py", line 295, in screenshot
value = self.http.get('screenshot').value
File "/usr/local/Cellar/python3/3.6.4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wda/init.py", line 101, in fetch
return self._fetch_no_alert(method, url, data)
File "/usr/local/Cellar/python3/3.6.4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wda/init.py", line 107, in _fetch_no_alert
return httpdo(target_url, method, data)
File "/usr/local/Cellar/python3/3.6.4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wda/init.py", line 77, in httpdo
retjson = response.json()
File "/usr/local/Cellar/python3/3.6.4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/models.py", line 892, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/local/Cellar/python3/3.6.4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/init.py", line 354, in loads
return _default_decoder.decode(s)
File "/usr/local/Cellar/python3/3.6.4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/Cellar/python3/3.6.4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
我用python3.6无法成功执行代码
有MAC+IOS的同学吗
webbrowser.open('https://baidu.com/s?wd=' + question)
这句代码打开浏览器(Safari),中文问题显示乱码
我尝试过在Safari里把默认编码改成Unicode,或者在python里encdoe('gb2312')均没法解决
请教大神有什么其他办法吗,感谢
运行GetQuestionTessAndroid.py的时候21行报错了:question, choices = ocr.ocr_img(img),大神知道是为啥吗?
请问是要自己配置还是需要特定的命令行工具
RT
具体可以查看https://github.com/lixinlong2014/666666
来源V2EX
采用方式 2 获取截图
-- 方法2: 题目+选项搜索结果计数法 --
Question: 歌曲 (康定情歌) 中的“康定”位
Traceback (most recent call last):
File "GetQuestionTessAndroid.py", line 28, in
methods.run_algorithm(1, question, choices)
File "/XXX/Maple/XXX/TopSup-master/common/methods.py", line 51, in run_algorithm
open_webbrowser_count(question, choices)
File "/XXX/XXX/XXX/TopSup-master/common/methods.py", line 16, in open_webbrowser_count
if '不是' in question:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 0: ordinal not in range(128)
➜ TopSup-master python3 GetQuestionTessIos.py
Traceback (most recent call last):
File "GetQuestionTessIos.py", line 23, in
question, choices = ocr.ocr_img(img)
File "/Users/Mac/Downloads/TopSup-master/common/ocr.py", line 64, in ocr_img
question = pytesseract.image_to_string(question_im, lang='chi_sim', config=tessdata_dir_config)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pytesseract/pytesseract.py", line 122, in image_to_string
config=config)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pytesseract/pytesseract.py", line 46, in run_tesseract
proc = subprocess.Popen(command, stderr=subprocess.PIPE)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 707, in init
restore_signals, start_new_session)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1326, in _execute_child
raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'C:\Program Files (x86)\Tesseract-OCR\tesseract'
$ python3 GetQuestionApi.py
/usr/local/Cellar/python3/3.6.4_1/Frameworks/Python.framework/Versions/3.6/Resources/Python.app/Contents/MacOS/Python: can't open file 'GetQuestionApi.py': [Errno 2] No such file or directory
help!
那个截图的那个流 能不能 不保存, 直接 就 给转成图片的格式
学到了很多, 非常感谢分享
Windows环境下运行报错:
python GetQuestionTessAndroid.py
采用方式 2 获取截图
Traceback (most recent call last):
File "GetQuestionTessAndroid.py", line 20, in <module>
question, choices = ocr.ocr_img(img)
File "D:\Download\ZSDT\code\TopSup\common\ocr.py", line 64, in ocr_img
question = pytesseract.image_to_string(question_im, lang='chi_sim', config=tessdata_dir_config)
File "D:\Project\Python3\lib\site-packages\pytesseract\pytesseract.py", line 123, in image_to_string
config=config)
File "D:\Project\Python3\lib\site-packages\pytesseract\pytesseract.py", line 47, in run_tesseract
proc = subprocess.Popen(command, stderr=subprocess.PIPE)
File "D:\Project\Python3\lib\subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "D:\Project\Python3\lib\subprocess.py", line 997, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] 系统找不到指定的文件。
这个是tesseract路径问题吗?已经填加了PATH,当前可执行tesseract
tesseract路径配置
# tesseract 路径
pytesseract.pytesseract.tesseract_cmd = 'D:\\Project\\Tesseract-OCR\\tesseract'
# 语言包目录
tessdata_dir_config = '--tessdata-dir "D:\\Project\\Tesseract-OCR\\tessdata" --psm 6'
README中提到的依赖已安装
flake8 testing of https://github.com/Skyexu/TopSup
$ time flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics
./GetQuestionTessIos.py:21:21: F821 undefined name 'ocr'
question, choices = ocr.ocr_img(img)
^
./GetQuestionTessIos.py:26:1: F821 undefined name 'methods'
methods.run_algorithm(0, question, choices)
^
./GetQuestionTessIos.py:28:1: F821 undefined name 'methods'
methods.run_algorithm(1, question, choices)
^
./GetQuestionTessIos.py:30:1: F821 undefined name 'methods'
methods.run_algorithm(2, question, choices)
^
./baiduApiVersion/GetTitleBaiduIos.py:39:10: F821 undefined name 'img'
region = img.crop((50, 350, 1000, 560)) # 坚果 pro1
^
pip freeze > requirements.txt
答题外挂已启动
采用方式 2 获取截图
Traceback (most recent call last):
File "/Users/wangpeng52/Downloads/TopSup-master/GetQuestionTessAndroid.py", line 21, in
question, choices = ocr.ocr_img(img)
File "/Users/wangpeng52/Downloads/TopSup-master/common/ocr.py", line 64, in ocr_img
question = pytesseract.image_to_string(question_im, lang='chi_sim', config=tessdata_dir_config)
File "/anaconda3/lib/python3.6/site-packages/pytesseract/pytesseract.py", line 122, in image_to_string
config=config)
File "/anaconda3/lib/python3.6/site-packages/pytesseract/pytesseract.py", line 46, in run_tesseract
proc = subprocess.Popen(command, stderr=subprocess.PIPE)
File "/anaconda3/lib/python3.6/subprocess.py", line 709, in init
restore_signals, start_new_session)
File "/anaconda3/lib/python3.6/subprocess.py", line 1344, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'C:\Program Files (x86)\Tesseract-OCR\tesseract': 'C:\Program Files (x86)\Tesseract-OCR\tesseract'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.