예제 #1
0
 def code_online(self, file_name):
     # self.get_code_image(file_name)
     r = ShowapiRequest("http://route.showapi.com/1274-2", "109836",
                        "e622838346714a869fa3deaaee8850b1")
     r.addFilePara("imgFile", file_name)
     res = r.post()
     print(res)
     text = res.json()['showapi_res_body']['texts']
     return text
 def code_online(self, file_name):
     ''' 解析图片获取验证码 '''
     self.get_code_image(file_name)
     r = ShowapiRequest("http://route.showapi.com/1274-2", "167812", "755663fd1ff740128b5c4c3663013e89")
     # r.addBodyPara("imgUrl", "http://pic.4j4j.cn/upload/pic/20130528/a9117a5351.jpg")
     # r.addBodyPara("base64", "")
     r.addFilePara("imgFile", file_name)
     res = r.post()
     text = res.json()["showapi_res_body"]['texts']
     yzm = ''.join(text)
     return yzm
예제 #3
0
    def code_online(self, file_name):
        self.get_code_image(file_name)
        r = ShowapiRequest("https://route.showapi.com/1274-2", "274787",
                           "1ea4e3d91ac3404da01b319403823a29")
        r.addFilePara("imgFile", file_name)  #文件上传时设置
        res = r.post()
        time.sleep(1)
        text = res.json()['showapi_res_body']
        #print(text)
        code = text['texts']

        return code
예제 #4
0
def code_online(file_name):
    r = ShowapiRequest("http://route.showapi.com/184-4","62626","d61950be50dc4dbd9969f741b8e730f5" )
    r.addBodyPara("typeId", "35")
    r.addBodyPara("convert_to_jpg", "0")
    r.addFilePara("image", file_name) #文件上传时设置
    res = r.post()
    print(res.text)
    text = res.json()['showapi_res_body']['Result']
    return text
예제 #5
0
 def code_online(self,file_name):
     self.get_code_image(file_name)
     r = ShowapiRequest("http://route.showapi.com/184-4", "451433", "14410a0d29ea4c62858bb3f07c7f3767")
     r.addBodyPara("typeId", "35")
     r.addBodyPara("convert_to_jpg", "0")
     r.addFilePara("image", file_name)
     res = r.post()
     print(res.text)
     text = res.json()['showapi_res_body']['Result']
     return text
예제 #6
0
 def get_code_picture(self):
     file_path = self.get_picture(self.file_path)
     r = ShowapiRequest("http://route.showapi.com/184-4", "110187",
                        "31fead27b6414c27b467e278ec3a62ed")
     r.addBodyPara("typeId", "35")
     r.addBodyPara("convert_to_jpg", "0")
     r.addFilePara("image", file_path)
     res = r.post()
     text = res.json()['showapi_res_body']['Result']
     return text
예제 #7
0
 def code_online(self,file_name):
     self.get_code_image(file_name)
     r = ShowapiRequest("http://route.showapi.com/184-4","62626","d61950be50dc4dbd9969f741b8e730f5" )
     r.addBodyPara("typeId", "35")
     r.addBodyPara("convert_to_jpg", "0")
     r.addFilePara("image", file_name) #文件上传时设置
     res = r.post()
     time.sleep(1)
     text = res.json()['showapi_res_body']
     code = text['Result']
     return code
     
예제 #8
0
    def code_online(self, file_name):
        self.get_code_image(file_name)  #卡在这不动啊
        r = ShowapiRequest("http://route.showapi.com/184-4", "62626",
                           "d61950be50dc4dbd9969f741b8e730f5")
        r.addBodyPara("typeId", "35")
        r.addBodyPara("convert_to_jpg", "0")
        r.addFilePara(
            "image",
            "D:/pyProject/PrimarySelenium/output/image/test002.png")  #文件上传时设置
        res = r.post()
        time.sleep(1)
        text = res.json()['showapi_res_body']
        print(text)
        code = text['Result']

        return code
예제 #9
0
 def code_online(self):
     r = ShowapiRequest("http://route.showapi.com/184-4", "103444",
                        "b8112ed5fc234f488fad6ef1d0c90ee1")
     # r.addBodyPara("img_base64", "")
     r.addBodyPara("typeId", "35")
     r.addBodyPara("convert_to_jpg", "0")
     r.addBodyPara("needMorePrecise", "0")
     r.addFilePara(
         "image", "C:/Users/xx/Desktop/SeleniumPython/register/test01.png")
     res = r.post()
     text = res.json()['showapi_res_body']['Result']
     return text
예제 #10
0
left = code_element.location["x"]
top = code_element.location["y"]
# 画像の幅と高さを取得
right = code_element.size['width'] + left
height = code_element.size["height"] + top

# 画像を修理
# pip install Pillow
from PIL import Image

im = Image.open("imooc.png")
img = im.crop((left, top, right, height))
img.save("imooc1.png")

# (外部api使用した)画像の文字認識
r = ShowapiRequest("http://route.showapi.com/184-5", "my_appId",
                   "my_appSecret")
r.addBodyPara("img_base64", "")
# typeid=画像内に数字の数
r.addBodyPara("typeId", "35")
r.addBodyPara("convert_to_jpg", "0")
r.addBodyPara("needMorePrecise", "0")
r.addFilePara("image", "imooc1.png")  #文件上传时设置
res = r.post()
text = res.json()['showapi_res_body']["Result"]
print(text)  # 返回信息

# 認識した数字を入力
time.sleep(3)
driver.find_element_by_id("captcha_code").send_keys(text)

driver.close()
예제 #11
0
 def code_online(self, file_name):
     self.get_code_image(file_name)
     r = ShowapiRequest("http://route.showapi.com/184-4", "101098",
                        "f6b3ad5dad704d429c54583d1c19207b")
     r.addBodyPara("img_base64", "utf-8")
     r.addBodyPara("typeId", "35")
     r.addBodyPara("convert_to_jpg", "0")
     r.addBodyPara("needMorePrecise", "0")
     r.addFilePara("image", file_name)
     res = r.post()
     print(res.text)
     text = res.json()['showapi_res_body']['Result']
     time.sleep(2)
     return text
예제 #12
0
 def code_online(self, file_name):
     self.get_code_image(file_name)
     r = ShowapiRequest("http://route.showapi.com/184-4", "103592",
                        "3388e72a386041dd85f8eb604914bcbd")
     r.addBodyPara("typeId", "35")
     r.addBodyPara("convert_to_jpg", "0")
     r.addFilePara("image", file_name)  #文件上传时设置
     r.addBodyPara("needMorePrecise", "0")
     res = r.post()
     text = res.json()['showapi_res_body']['Result']
     time.sleep(2)
     return text
예제 #13
0
def parseImg(file_name):
    getImg(file_name)
    r = ShowapiRequest("http://route.showapi.com/184-5", "91267",
                       "1dbeca97548a4923adea21e917b3df8b")
    r.addBodyPara("typeId", "35")
    r.addBodyPara("convert_to_jpg", "0")
    r.addBodyPara("needMorePrecise", "0")
    r.addFilePara("image", file_name)  #文件上传时设置
    res = r.post()
    return res.json()['showapi-res_body']['Result']
예제 #14
0
 def discern_captcha_image(self, file_name):
     self.get_captcha_image(file_name)
     # 解析验证码图片中的文字(用第三方的图片验证码识别接口 ShowApiRequest)
     r = ShowapiRequest("http://route.showapi.com/184-4", "156943", "889229f1478e460883969df323f4865f")
     r.addBodyPara("img_base64", "")
     r.addBodyPara("typeId", "35")
     r.addBodyPara("convert_to_jpg", "0")
     r.addBodyPara("needMorePrecise", "0")
     r.addFilePara("image", file_name)  # 文件上传时设置
     res = r.post()
     text = res.json()["showapi_res_body"]["Result"]
     return text
예제 #15
0
def code_online(file_name):
    r = ShowapiRequest("http://route.showapi.com/184-5", "my_appId",
                       "my_appSecret")
    r.addBodyPara("img_base64", "")
    # typeid=画像内に数字の数
    r.addBodyPara("typeId", "35")
    r.addBodyPara("convert_to_jpg", "0")
    r.addBodyPara("needMorePrecise", "0")
    r.addFilePara("image", file_name)  # 文件上传时设置
    res = r.post()
    text = res.json()['showapi_res_body']["Result"]
    return text
예제 #16
0
 def code_online(self, file_name):
     self.get_code_image(file_name)
     r = ShowapiRequest("http://route.showapi.com/184-4", "166211",
                        "a0459474e9f9489ab29a31ddb96bae51")
     r.addFilePara("image", file_name)
     r.addBodyPara("typeId", "35")
     r.addBodyPara("convert_to_jpg", "0")
     r.addBodyPara("needMorePrecise", "0")
     res = r.post()
     text = res.json()['showapi_res_body']['Result']
     time.sleep(2)
     return text
예제 #17
0
from PIL import Image
from util.ShowapiRequest import ShowapiRequest
import time

file_name = r"D:/1/test001.jpg"
r = ShowapiRequest("https://route.showapi.com/1274-2", "274787",
                   "1ea4e3d91ac3404da01b319403823a29")
r.addFilePara("imgFile", "D:/1/test001.png")  #文件上传时设置
res = r.post()
time.sleep(1)
print(res)
text = res.text
print(text)
code = text['remark']
print(code)
예제 #18
0
#coding:utf-8
import pytesseract
from PIL import Image
from util.ShowapiRequest import ShowapiRequest
#image = Image.open("E:/imooc1.png")
#text = pytesseract.image_to_string(image)
#print(text)
r = ShowapiRequest("http://route.showapi.com/184-4", "101098",
                   "f6b3ad5dad704d429c54583d1c19207b")
r.addBodyPara("img_base64", "utf-8")
r.addBodyPara("typeId", "35")
r.addBodyPara("convert_to_jpg", "0")
r.addBodyPara("needMorePrecise", "0")
r.addFilePara("image", r"E:/imooc1.png")
res = r.post()
text = res.json()['showapi_res_body']['Result']
print(text)  # 返回信息
예제 #19
0
top = point['y']
print('验证码图片左上角点的坐标:',point)
size = element.size  # 验证码图片的大小
right = left + size['width'] 
bottom = top + size['height']
print('验证码图片的大小', size)
# 打开原图
img_orig = Image.open(
    '/Users/edz/Documents/lab/imooc/img/Register.png')
# 在原截图上截取验证码图片
img_final = img_orig.crop((left*2, top*2, right*2, bottom*2))
# img_final = img_orig.crop((680, 563, 809, 563))
img_final.save('/Users/edz/Documents/lab/imooc/img/CropRegister.png')
# 图片转换文字
#pytesseract.image_to_string(
#    '/Documents/lab/imooc/img/CropRegister.png')
time.sleep(5)'''


r = ShowapiRequest("http://route.showapi.com/184-5","91267","1dbeca97548a4923adea21e917b3df8b" )
r.addBodyPara("typeId", "35")
r.addBodyPara("convert_to_jpg", "0")
r.addBodyPara("needMorePrecise", "0")
r.addFilePara("image", r"/Users/edz/Documents/lab/imooc/img/CropRegister.png") #文件上传时设置
res = r.post()
print(res.text) # 返回信息


# driver.close()