头脑王者python 辅助外挂


# coding: utf-8
import os
import shutil
import time
import math
import wda
from PIL import Image, ImageDraw
import random
import json
import webbrowser
import  urllib



c = wda.Client()
s = c.session()

def pull_screenshot():
    c.screenshot('1.png')
    im = Image.open("./1.png")

    # iPhone6sP
    x = 100
    y = 600
    w = 1000
    h = 400

    # iPhone6s
    # x = 75
    # y = 350
    # w = 600
    # h = 250
    region = im.crop((x, y, x + w, y + h))

    #第一步 截取题目区域图片
    region.save('dog.jpg')


def main():
    # while True:
        pull_screenshot()

        cmd = 'tesseract  dog.jpg content -l chi_sim'

        # 2。识别图片内容并保存到文本
        os.popen(cmd)

        file_object = open('content.txt')
        try:

            # 3.获取文本内容
            all_the_text = file_object.read()

            s = all_the_text
            p = {'wd': s}

            #4.百度
            url = "http://www.baidu.com/s?" + urllib.urlencode(p)
            webbrowser.open(url)

            print (all_the_text)
        finally:
            file_object.close()



if __name__ == '__main__':
    main()

你可能感兴趣的:(头脑王者python 辅助外挂)