g15009428458

<!doctype html>

selenium和百度ai智能图像识别

selenium和百度ai智能图像识别

在百度ai图像识别中创建应用,获取工具码

from selenium import webdriver
import time

from aip import AipOcr

def initial():
#ai工具码
""" 初始化连接 """
APP_ID = \'16611607\'
API_KEY = \'wAIXfXOUS8ztLa4FrK3rZex1\'
SECRET_KEY = \'3b8nvjSGUZq0LPC18VVAizKYRBbny6Mq\'
return AipOcr(APP_ID, API_KEY, SECRET_KEY)

def get_file_content(filePath):
""" 读取图片 """
print(333333333333333, filePath)
with open(filePath, \'rb\') as f:
return f.read()

def get_file_content(filePath):
"""读取图片"""
print(333333333, filePath)
with open(filePath,\'rb\') as f:
return f.read()

def selenium_msg():
driver = webdriver.Chrome()
try:
driver.get(\'https://pythonav.com/login/\')
time.sleep(1)
driver.find_element_by_id(\'id_username\').send_keys("guo")
time.sleep(1)
driver.find_element_by_id(\'id_password\').send_keys("123")

    image = driver.find_element_by_id(&#39;image_code&#39;)

    file_path = &quot;b.png&quot;
    image.screenshot(file_path)

    #百度ai
    client = initial()
    image = get_file_content(file_path)
    print(4444444, image)
    res1 = client.basicGeneral(image)
    print(res1)
    driver.find_element_by_id(&#39;id_code&#39;).send_keys(res1[&#39;words_result&#39;][0][&#39;words&#39;])
    time.sleep(2)
    driver.find_element_by_class_name(&#39;btn-primary&#39;).click()
finally:
    time.sleep(5)
    driver.quit()

if name == \'main\':
selenium_msg()

 

分类:

技术点:

相关文章:

  • 2021-11-11
  • 2022-12-23
  • 2021-10-16
  • 2022-12-23
  • 2021-11-27
猜你喜欢
  • 2021-10-16
  • 2021-10-16
  • 2021-11-09
  • 2021-09-23
  • 2021-10-16
相关资源
相似解决方案