识别网络图像文字

import requests

import json

#获取百度服务器的access_token

url="https://aip.baidubce.com/oauth/2.0/token"

params1={

"grant_type":"client_credentials",

    "client_id":"IAmP4hTYUwjbmvEdDa5PGWnP",

    "client_secret":"T2KmKo0ruwZ2grHRDKTUCzAjGXWDwY98"

}

res=requests.get(url=url,params=params1)

# print(res.text,type(res.text))

res=json.loads(res.text)

# print(res,type(res))

access_token=res["access_token"]

print(access_token,type(access_token))

#识别网络文件图像的文字

url1="https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic?access_token="

new_url=url1+access_token

headers={"Content-Type":"application/x-www-form-urlencoded"}

data={"url":"http://upload-images.jianshu.io/upload_images/7575721-40c847532432e852.png?imageMogr2/auto�orient/strip%7CimageView2/2/w/1240"}

res1=requests.post(url=new_url,headers=headers,data=data)

你可能感兴趣的:(识别网络图像文字)