I've been trying to scrape data from Fantasy Premier League (https://fantasy.premierleague.com) and when I try to login through requests module in Python, I get the 405 error.
To get the data I need, first I need to log-in to the site. So, I manually entered my username and password in a json format after getting the ids from the webpage. I also included the hidden fields the form required. I created a Session variable and sent a post request to the the site with this data variable for the data parameter,
import requests
session = requests.Session()
data = {
"loginUsername" : "username",
"loginPassword" : "password",
"app" : "plfpl-web",
"redirect_uri" : "https://fantasy.premierleague.com/"
}
url = "https://fantasy.premierleague.com/"
login = session.post(url, data = data)
print(login.text)
And I get the following output
<html>
<head><title>405 Not Allowed</title></head>
<body bgcolor="white">
<center><h1>405 Not Allowed</h1></center>
<hr><center>nginx/1.13.5</center>
</body>
</html>
I tried the same method for different sites, such as Twitter and got either 405 or 403 error message like above.
What can I change to get the request successfully? I know I can use Selenium, but I'm planning on making a small project and distributing to others and I want the data scraping to happen without the browser drivers.