0
我試圖檢查一個電子郵件是否已經存在於一個網站中。目前使用Postman的示例Python代碼。Python請求Postman的代碼片段
的作品示例代碼:
import requests
url = "https://registration.mercadolivre.com.br/registration/"
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"signUp.email\"\r\n\r\[email protected]\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"signUp.repEmail\"\r\n\r\[email protected]\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"signUp.newsletter\"\r\n\r\ntrue\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"source\"\r\n\r\nmercadolibre\r\n-----011000010111000001101001--"
headers = {
'content-type': "multipart/form-data; boundary=---011000010111000001101001",
'cache-control': "no-cache",
'postman-token': "179cabe2-dd22-490e-8fbd-15bf2977feb5"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
我不知道爲什麼郵差編碼該字符串的有效載荷。當我試圖通過一本字典它不工作了
不起作用代碼:
import requests
url = "https://registration.mercadolivre.com.br/registration/"
payload = { 'signUp.email': '[email protected]',
'signUp.repEmail': '[email protected]',
'signUp.newsletter': 'true',
'source': 'mercadolibre' }
headers = {
'content-type': "multipart/form-data; boundary=---011000010111000001101001",
'cache-control': "no-cache",
'postman-token': "22a12fa5-5f68-685c-124d-db0ef6eb334c"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
我很奇怪,爲什麼我不能通過一個JSON或字典。
實際上Json版本不起作用,因爲輸出是不同的。它說「MercadoLivre - Ocorreu um erro」。當我使用郵遞員推薦的方法時,結果與郵件說已經在使用的消息不同。 – Legos