1
我試圖獲得成功的登錄帖子請求,但不明白爲什麼我總是得到狀態碼405。我查了很多教程,並且它們都適用於某些示例。爲什麼我在發送郵件請求時收到「方法不允許(HTTP代碼405)」?
import requests
import urllib.parse
def logintest(usr, pswd):
link = 'link'
headers = { 'Content-Type' : 'application/x-www-form-urlencoded',
'Server' : 'Apache-Coyote/1.1',
'Transfer-Encoding' : 'chunked'
}
payload = urllib.parse.urlencode({
'username': usr,
'password': pswd
})
responseget = requests.get(link)
print (responseget.status_code, responseget.reason)
if responseget.status_code == 200:
responsepost = requests.post(link, params = payload, headers = headers)
print (responsepost.status_code, responsepost.reason)
logintest('username', 'password')
工作正常,鏈接錯誤,應該關閉:/ –