資源簡(jiǎn)介
Python-沖頂大會(huì)芝士超人西瓜視頻頭腦王者百萬英雄等答題輔助瞬間打開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)??
#?定義參數(shù)變量??
options?=?{??
??‘detect_direction‘:?‘true‘??
??‘language_type‘:?‘CHN_ENG‘??
}??
#利用adb從手機(jī)中獲取屏幕事實(shí)截圖,并pull到計(jì)算機(jī)上
def?pull_screenshot():
????os.system(‘a(chǎn)db?shell?screencap?-p?/sdcard/screenshot.png‘)
????os.system(‘a(chǎn)db?pull?/sdcard/screenshot.png?.‘)
#?根據(jù)你的手機(jī)配置屏幕截圖信息,我的測(cè)試手機(jī)是meizu_pro6s配置如下
#?沖頂大會(huì)圖片切割
def?image_cut_chongding():
????img?=?Image.open(“./screenshot.png“)
????#區(qū)域由一個(gè)4元組定義,表示為坐標(biāo)是?(x0?y0?x1?x2)
????#問題區(qū)域
????question??=?img.crop((38?316?1032640))
????question.save(‘question.png‘)
????#選線區(qū)域
????choices?=?img.crop((38?640?1032?1226))
????choices.save(‘choices.png‘)
#西瓜視頻圖片切割
def?image_cut_xigua():
????img?=?Image.open(“./screenshot.png“)
????#區(qū)域由一個(gè)4元組定義,表示為坐標(biāo)是?(x0?y0?x1?x2)
????#問題區(qū)域
????question??=?img.crop((38?300?1017624))
????question.save(‘question.png‘)
????#選線區(qū)域
????choices?=?img.crop((38?624?1017?1257))
????choices.save(‘choices.png‘)
#芝士超人圖片切割
def?image_cut_zhishi():
????img?=?Image.open(“./screenshot.png“)
????#區(qū)域由一個(gè)4元組定義,表示為坐標(biāo)是?(x0?y0?x1?x2)
????#問題區(qū)域
????question??=?img.crop((21?285?1056570))
????question.save(‘question.png‘)
????#選線區(qū)域
????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識(shí)別問題文字
def?question_words(q_filePathoptions):
????#?調(diào)用通用文字識(shí)別接口
????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
#?讀取選項(xiàng)圖片????
def?get_file_content(c_filePath):??
????with?open(c_filePath?‘rb‘)?as?fp:??
????????return?fp.read()
#?OCR識(shí)別問題文字
def?choices_words(c_filePathoptions):
????#?調(diào)用通用文字識(shí)別接口
????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
#網(wǎng)頁(yè)分析統(tǒng)計(jì)
def?count_base(questionchoices):
????#print(‘題目搜索結(jié)果包含選項(xiàng)詞頻計(jì)數(shù)‘)
????#?請(qǐng)求
????req?=?requests.get(url=‘http://www.baidu.com/s‘?params={‘wd‘:question})
????content?=?req.text
????#print(content)
????counts?=?[]
????dic?=?{}
????print(Fore.YELLOW?+‘-----------------歡迎你使用賣假貨學(xué)長(zhǎng)的小助手---------------------------‘+?Fore.RESET)
????print(‘問題:?‘+question)
????#print(‘———————————————————————————‘)
????if?‘不是‘?in?question?or?‘不能‘?in?question?or?‘不屬于‘?in?question??or?‘不可以‘?in?question?or?‘不包括‘?in?question:
????????print(‘—
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????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
評(píng)論
共有 條評(píng)論