steveyg / AnswerHelper

直播答题辅助工具(适用于 冲顶大会/芝士超人/百万赢家/西瓜视频/黄金十秒)
114 stars 47 forks source link

有报错求指导 #5

Closed fcc04101405 closed 6 years ago

fcc04101405 commented 6 years ago

Traceback (most recent call last): File "main.py", line 10, in result = problem_utils.get_result() File "/Users/fengchengcheng/Downloads/AnswerHelper-master/problem_utils.py", line 56, in get_result return get_chongding_by_api() File "/Users/fengchengcheng/Downloads/AnswerHelper-master/problem_utils.py", line 39, in get_chongding_by_api while(json.loads(req.text)['msg'] != u"成功"): File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/init.py", line 338, in loads return _default_decoder.decode(s) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 366, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 384, in raw_decode raise ValueError("No JSON object could be decoded") ValueError: No JSON object could be decoded

有报错,不知道是咋回事,大神能指导一下么

steveyg commented 6 years ago

出现这个说明没问题了,因为那个接口只有答题的时候有数据,所以平时会报这个错误

p1094358629 commented 6 years ago

关于这个错误,我看了源码不是很明白,是什么事件开始出发截屏的呢??? 我们运行main之后,系统系统在干什么呢???

steveyg commented 6 years ago

@p1094358629 是这样的,这个脚本分为两个模式,一种是截屏,一种是调接口,出现这个问题是因为接口没有数据导致的,如果是截屏模式,截屏在Img_utils中的spot中调用

p1094358629 commented 6 years ago

@steveyg 我昨天在公司的时候用您的项目,模式是冲顶大会的,当我运行main.py,貌似进程会等待msg,有数据就会直接跳到web。而今天这个如果没有msg,直接报题目这个错???我需要不停的运行main.py,请问这是为什么呢???

steveyg commented 6 years ago

@p1094358629 我也发现了这个问题,正在排查中

p1094358629 commented 6 years ago

@steveyg 您这个api 挺有意思的啊,能看下源码吗???

steveyg commented 6 years ago

@p1094358629 api是别人提供的,见https://github.com/steveyg/AnswerHelper/issues/1

steveyg commented 6 years ago

问题已修复,原因是之前访问太频繁导致报了403错误 修改见https://github.com/steveyg/AnswerHelper/commit/8594421edc059435dd8fb554c84ebc952f0d0b61

fcc04101405 commented 6 years ago

好像今天晚上答题接口一直返回没数据

steveyg commented 6 years ago

嗯,获取题目的接口好像用不了了,先暂时用ocr的方式吧

fcc04101405 commented 6 years ago

/sdcard/screenshot.png: 1 file pulled. 12.0 MB/s (960500 bytes in 0.076s) Traceback (most recent call last): File "main.py", line 10, in result = problem_utils.get_result() File "/Users/fengchengcheng/Downloads/AnswerHelper-master/problem_utils.py", line 58, in get_result return get_by_scan() File "/Users/fengchengcheng/Downloads/AnswerHelper-master/problem_utils.py", line 14, in get_by_scan words = img_utils.spot()['words_result']; File "/Users/fengchengcheng/Downloads/AnswerHelper-master/img_utils.py", line 49, in spot get_android_img(); File "/Users/fengchengcheng/Downloads/AnswerHelper-master/img_utils.py", line 18, in get_android_img crop() File "/Users/fengchengcheng/Downloads/AnswerHelper-master/img_utils.py", line 33, in crop plt.imshow(img), plt.axis('off') File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/pyplot.py", line 2892, in imshow imlim=imlim, resample=resample, url=url, **kwargs) File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/axes.py", line 7300, in imshow im.set_data(X) File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/image.py", line 419, in set_data self._A = pil_to_array(A) File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/image.py", line 1347, in pil_to_array x = toarray(im) File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/image.py", line 1313, in toarray x_str = im.tostring('raw', im.mode) File "/Library/Python/2.7/site-packages/PIL/Image.py", line 740, in tostring raise NotImplementedError("tostring() has been removed. " NotImplementedError: tostring() has been removed. Please call tobytes() instead. 用ocr好像报这个错,没学过python,为啥tostring()这个方法被removed了。。。是版本问题么。。

fcc04101405 commented 6 years ago

靠度娘解决了。。。 改了一下Image.py的tostring方法的代码,注释掉了上面这句,改成了return self.tobytes()

steveyg commented 6 years ago

这是库的问题?

fcc04101405 commented 6 years ago

好像是,百度好像说得pillow版本3.0以下,以上的好像tostring就不支持。。。