I'm currently trying to write a python script to log in to a website. Access requires an email and password.
Which module is best for this? My current script uses the requests module, but is unsuccessful as the websites source code retrieved shows the following status:
ERROR
</title></head>
<body>
<div id="fb-root"></div>
<script type="text/javascript">
//Base variables
var IsLoggedOn = false;
var CurrentUserId = 0;
var EventFollowingHash = 6864;
var AjaxSource = 'http://www.iex.nl';
</script>
Here's my code:
import requests
with requests.Session() as c:
url = "WEBSITE URL"
USERNAME = "VALID EMAIL"
PASSWORD = "VALID PASSWORD"
c.get(url)
login_data = dict(username=USERNAME, password=PASSWORD, next='/')
c.post(url, data=login_data, headers={"Referer":"WEBSITE URL"})
page = c.get("PROTECTED LAYER OF WEBPAGE")
print page.content
Help welcome, this one's been troubling me for a while!!