CloudSight:https://www.cloudsightapi.com/
> python cloudsight.pyhttp://url/test.jpg
#!/usr/bin/env python# coding=utf8# author=evi1m0@2015importsysimporttimeimportrequestsdef_api(url):count=0api_url='http://api.cloudsightapi.com/image_requests'res_url='http://api.cloudsightapi.com/image_responses/'headers={'Origin':'http://cloudsightapi.com','HOST':'api.cloudsightapi.com','Authorization':'CloudSight amZd_zG32VK-AoSz05JLIA',}post_data={'image_request[remote_image_url]':url,'image_request[locale]':'zh-CN','image_request[language]':'zh-CN',}token_req=requests.post(api_url,data=post_data,headers=headers)token=token_req.json()['token']whilecount<10:try:count+=1print'[+] Loading...'result=requests.get('%s%s'%(res_url,token),headers=headers)status=result.json()['status']ifstatus=='completed':print'[+] Pic:%s'%urlprint'[*] Name:%s'%result.json()[u'name']breakexceptException,e:print'[-] False:%s'%str(e)passif__name__=='__main__':try:url=sys.argv[1]_api(url)exceptException,e:print'Usage: cloudsightapi.py http://pic_url.com/test.jpg'print'Error:%s'%str(e)pass
Result
图像识别因调用接口可能时间较久,可根自身需求修改重试次数变量count。
网友评论