1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- import json
- from urllib.parse import urlencode
- import requests
- import ssl
- import certifi
- import base64
- ssl_context = ssl.create_default_context()
- ssl_context.load_verify_locations(certifi.where())
- def image_code(image_path):
- with open(image_path, 'rb') as image_file:
- imageStr = base64.b64encode(image_file.read()).decode('utf-8')
- url = "https://codevirify.market.alicloudapi.com/icredit_ai_image/verify_code/v1"
- # payload = 'IMAGE=https%3A%2F%2Ficredit-api-market.oss-cn-hangzhou.aliyuncs.com%2F%25E9%25AA%258C%25E8%25AF%2581%25E7%25A0%2581.jpg&IMAGE_TYPE=1'
- # imageStr = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAG4AAAAgCAYAAADzCU3nAAABLWlDQ1BTa2lhAAAokX2QPUjDUBSFP0tB/MFFRQeHOOmithWrBR1MwSJurUJ1S9NQxLaGNEWdu7q7OrvqqLs4CYKDOLi4C4JrPa8ZUpB6D5f7ce59ebkPErMokiloNMOgWLCt8uGRNfzBkNQLx235DA5N/bxGsy9L/8wNipGq13JVv5RhoMv1yap4qhbxueFKxJeGz0I/FF8bDvaLefGdeLHWx5U+dv3AzL+LNxv1thv/N+Ne86CkWlbOUeBUqlHHY4USJxzjiNLSDinWpCw5trF71fjrqsZdVT8n2WTUzyrzohwbpMx7Rld25mHrotvt3sfe3jPcPsDoW+wtfMLEEzxexV78xr4TOD0rqUx4NnxPa5UbmNS5sY7cGdMesKv1Z1eLXZq4LIsy2iNN9hcm/056/TWGNQAAEVZJREFUaIHtmnl8lNW5x7/vO2tmJsnMZLKTDRKSAEnYExZZrCgiiIVCi9Taj7a1tnqvWltbW629t9eil6q1m9rWq9alIKBsggVkiyTIKiSBhECSyTbJZCazZiazvf0jNJiakAmC9/O5199/c95zzu95z2/O8zznOa8gSZLECFDbWc1vdv+CP9y+fiTDvsBVhjiSzhISjh47Rp3pWtnzBaKEMJId5+l18f03vsqrd+24ljZ9gSgwoh1X0bCfkqzSa2XLFxgBRrTjbnluCtsf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hNn6Px+h1shJVmt5xVyNPtxIUK5lZkIxCxb9gMd+v5LegJ/nfrSbwuIri+2X/SjCGfYRJoIz0lfykiQJV6QHpSAjTrxUR9NqVeTlpfKtu2/oT2EFIQaNehaiaESpGIdCnjcox3BYkfUwbzetJRjpZYN57RXN8Xni3ZcqmXVLIb29FiL2jcyOsaHTjkMRsjBK4SMrOY8n7n2LX/3bJu55Yg511dYr4vkH/FftoGWjU4QAAAAASUVORK5CYII='
- imageStr = 'data:image/png;base64,' + imageStr
- params = {'IMAGE': imageStr, 'IMAGE_TYPE': '0'}
- payload = urlencode(params)
- print(payload)
- headers = {
- 'Authorization': 'APPCODE 713e3120bfc44e6187ca8e2102d00409 ',
- # 'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
- 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8'
- }
- response = requests.request("POST", url, headers=headers, data=payload)
- text = response.text
- print(response.headers)
- print(response.reason)
- print(response.status_code)
- print(response.text)
- # text = '{"VERIFY_CODE_STATUS": "艾科瑞特,让企业业绩长青", "VERIFY_CODE_ENTITY": {"VERIFY_CODE": "3X1Z"}}'
- json_data = json.loads(text)
- code = json_data["VERIFY_CODE_ENTITY"]["VERIFY_CODE"]
- print(code)
- return code
- if __name__ == '__main__':
- image_code('pig.png')
|