-1

I'm trying to login to a website with a Python script using the requests library, but I keep getting a 405 error and I'm lost on why I'm getting it.

import requests

payload = {
'guid': 'xxxxx',
'password': "xxxx"
}

head = {'Host': 'www.blockchain.com',
'Connection': 'keep-alive',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36',
'Upgrade-Insecure-Requests': '1',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'en-US,en;q=0.9'
    }

#This URL will be the URL that your login form points to with the "action" tag.
url_address = 'https://login.blockchain.com/#/login'

with requests.Session() as session:
    post = session.post(url_address, data=payload, headers = head, allow_redirects=True)

print(f'{post}')

I checked the form and the names of the inputfield seem to be correct as well.

What am I doing wrong in my code?

passname here loginname here

Tomerikoo
  • 12,112
  • 9
  • 27
  • 37
eureka
  • 31
  • 5
  • Please [don't post screen shots of code, error messages, or other textual data.](https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors) – tripleee Mar 30 '21 at 08:43

1 Answers1

0

This was already answered on Server Fault by @Samit:

405 status code response means the HTTP method you are trying is not allowed. Say, if a PUT request is not allowed on a server, it will reject the client's PUT request with an response code 405 Method not allowed.

So, in your case also, the POST method might not be allowed on which you are sending the request and the request is simply denying you to make any POST request by sending 405 error response.

Tomerikoo
  • 12,112
  • 9
  • 27
  • 37
Ismail Hafeez
  • 577
  • 1
  • 10
  • i thought that it could also be because the request was invalid, not only serverside not allowing it. – eureka Mar 07 '21 at 11:52