I'm trying to login through a site that is password protected in order to get access to a protected page, i have the email and password names along with the csrf-token.But when i try to access the protected page it doesnt allow me and redirects me back to the login.Any help would be awesome!The site im trying to access is.
import requests
from lxml import html
session_requests = requests.session()
login_url = "http://ift.tt/1FSoZIZ"
result = session_requests.get(login_url)
tree = html.fromstring(result.text)
authenticity_token = list(set(tree.xpath("//meta[@name='csrf-token']/@content")))[0]
userInfo = {
"user[email]": "email",
"user[password]": "password",
"csrf-token": authenticity_token
}
result = session_requests.post(
login_url,
data = userInfo,
headers = dict(referer=login_url)
)
url = 'http://ift.tt/2qYQEJV'
result = session_requests.get(
url,
headers = dict(referer = url)
)
print result.content
Aucun commentaire:
Enregistrer un commentaire