1
我需要別人幫助的Python下面捲曲要求:的Python如何使捲曲請求
curl --data "username=USERNAME&password=PASSWORD" --header "Authorization: Basic Y2xvdWQtYXBp" -X POST "https://ApiCallUrl/auth/token?grant_type=password" --insecure
我有以下代碼:
url = 'https://referencedatacloudauth.sit.icg.citigroup.net/auth/token?grant_type=velocity_169234/securities/products?search={"Xref.CSP":"G6264VAA0"}'
data = "username=velocity_169234&password=velocity_69234"
header = {'Authorization': b'Basic' + b64encode(('cloud-api').encode('utf-8'))}
data = urlencode(dict(username='USERNAME',password='PASSWORD')).encode('ascii')
response = urlopen(Request(url, data, header))
print(response.info())
如何添加--insecure
標誌?
我收到此錯誤
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)>
Python 3'urlopen'要求您傳遞'bytes'實例,而不是字符串。或者將data.encode('utf-8')'而不是'data'傳遞給'urlopen'方法或將'b'前綴添加到數據字符串定義中。 G。 'data = b「username = ...&password = ...」' –
使用'urllib.parse'庫進行數據解析。所以基本上你必須這樣做。 –
我更改了我的代碼以使用'urllib.parse'仍然錯誤。 –