資源簡介
Python-沖頂大會芝士超人西瓜視頻頭腦王者百萬英雄等答題輔助瞬間打開chrome百度.zip

代碼片段和文件信息
#?-*-?coding:?utf-8?-*-
#?@Author??:?Allen_Liang
#?@Time????:?2018/1/14?15:38
from?aip?import?AipOcr??
import?requests
import?json
import?time
from?PIL?import?Image
import?os
import?matplotlib.pyplot?as?plt
import?webbrowser
import?urllib.parse
#命令行顏色包
from?colorama?import?initFore
init()
#?百度OCR_api定義常量
#?輸入你的API信息??
APP_ID?=?‘‘??
API_KEY?=?‘‘??
SECRET_KEY?=?‘‘??
aipOcr?=?AipOcr(APP_ID?API_KEY?SECRET_KEY)??
#?定義參數變量??
options?=?{??
??‘detect_direction‘:?‘true‘??
??‘language_type‘:?‘CHN_ENG‘??
}??
#利用adb從手機中獲取屏幕事實截圖,并pull到計算機上
def?pull_screenshot():
????os.system(‘adb?shell?screencap?-p?/sdcard/screenshot.png‘)
????os.system(‘adb?pull?/sdcard/screenshot.png?.‘)
#?根據你的手機配置屏幕截圖信息,我的測試手機是meizu_pro6s配置如下
#?沖頂大會圖片切割
def?image_cut_chongding():
????img?=?Image.open(“./screenshot.png“)
????#區域由一個4元組定義,表示為坐標是?(x0?y0?x1?x2)
????#問題區域
????question??=?img.crop((38?316?1032640))
????question.save(‘question.png‘)
????#選線區域
????choices?=?img.crop((38?640?1032?1226))
????choices.save(‘choices.png‘)
#西瓜視頻圖片切割
def?image_cut_xigua():
????img?=?Image.open(“./screenshot.png“)
????#區域由一個4元組定義,表示為坐標是?(x0?y0?x1?x2)
????#問題區域
????question??=?img.crop((38?300?1017624))
????question.save(‘question.png‘)
????#選線區域
????choices?=?img.crop((38?624?1017?1257))
????choices.save(‘choices.png‘)
#芝士超人圖片切割
def?image_cut_zhishi():
????img?=?Image.open(“./screenshot.png“)
????#區域由一個4元組定義,表示為坐標是?(x0?y0?x1?x2)
????#問題區域
????question??=?img.crop((21?285?1056570))
????question.save(‘question.png‘)
????#選線區域
????choices?=?img.crop((21?578?1063?1172))
????choices.save(‘choices.png‘)
#?讀取問題圖片??
def?get_file_content(q_filePath):??
????with?open(q_filePath?‘rb‘)?as?fp:??
????????return?fp.read()
#?OCR識別問題文字
def?question_words(q_filePathoptions):
????#?調用通用文字識別接口
????result?=?aipOcr.basicGeneral(get_file_content(q_filePath)?options)
????q_Result_s=‘‘
????words_list=[]
????for?word_s?in?result[‘words_result‘]:
????????words_list.append(word_s[‘words‘])
????q_Result_s?=?q_Result_s.join(words_list)
????#print(q_Result_s)
????return?q_Result_s
#?讀取選項圖片????
def?get_file_content(c_filePath):??
????with?open(c_filePath?‘rb‘)?as?fp:??
????????return?fp.read()
#?OCR識別問題文字
def?choices_words(c_filePathoptions):
????#?調用通用文字識別接口
????result?=?aipOcr.basicGeneral(get_file_content(c_filePath)?options)
????c_Result_s=‘‘
????words_list=[]
????for?word_s?in?result[‘words_result‘]:
????????words_list.append(word_s[‘words‘])
????return?words_list
#網頁分析統計
def?count_base(questionchoices):
????#print(‘題目搜索結果包含選項詞頻計數‘)
????#?請求
????req?=?requests.get(url=‘http://www.baidu.com/s‘?params={‘wd‘:question})
????content?=?req.text
????#print(content)
????counts?=?[]
????dic?=?{}
????print(Fore.YELLOW?+‘-----------------歡迎你使用賣假貨學長的小助手---------------------------‘+?Fore.RESET)
????print(‘問題:?‘+question)
????#print(‘———————————————————————————‘)
????if?‘不是‘?in?question?or?‘不能‘?in?question?or?‘不屬于‘?in?question??or?‘不可以‘?in?question?or?‘不包括‘?in?question:
????????print(‘—
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-09-07?16:28??answer_the_question-master\
?????文件????????1482??2018-09-07?16:28??answer_the_question-master\README.md
?????文件????????6302??2018-09-07?16:28??answer_the_question-master\answer_the_question.py
?????文件?????????605??2018-09-07?16:28??answer_the_question-master\cut_images-size.py
?????目錄???????????0??2018-09-07?16:28??answer_the_question-master\example_images\
?????文件???????31074??2018-09-07?16:28??answer_the_question-master\example_images\1.jpg
?????文件???????41662??2018-09-07?16:28??answer_the_question-master\example_images\2.jpg
?????文件??????382310??2018-09-07?16:28??answer_the_question-master\example_images\one.jpg
?????文件??????312138??2018-09-07?16:28??answer_the_question-master\example_images\three.JPG
?????文件??????492515??2018-09-07?16:28??answer_the_question-master\example_images\two.jpg
?????文件???????29313??2018-09-07?16:28??answer_the_question-master\example_images\zuixin.JPG
評論
共有 條評論