Token and auth-token - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html) +--- Thread: Token and auth-token (/thread-20033.html) |
Token and auth-token - hshivaraj - Jul-24-2019 Hey all. I have problem which i dont quite understand how to go about from here. I use request library to sign-in to website and I believe im doing that right. I make a post request to /sign-in page and response to the POST request is following b'{"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjEuNTYzOTkyOTMzRTksImFwaV90b2tlbiI6ImFmYmRmZGRmMmVmMDRjYTE4NmUxZmQ2ZWU5MWM3MmE4IiwiZW1haWwiOiJwY2FicmVyb0BnbWFpbC5jb20iLCJ1dWlkIjoiNDdkYjEzYTMtY2ZkYy00NmRmLWE3OTgtYmUzMjI1MDcxYThiIn0.VQdYwBWlEkqewFQd72K2BA4Zd9aP6mQ_42uYsDgx9Ao","auth_token":"CNxnJqAuUPeeH12TB3BEaE1lU1LR4+8gkaQQjDGRoxkJ3ApQrgNXGAMwu5t8TvevBnjHp31XLNQvtonJEaJUtQ=="}'I basically expecting some html back if the login was successful. But instead I get these token. What do I do with these token from here. My code looks like this. with requests.Session() as s: url = "https://app.nutmeg.com/auth/users/sign_in" url2 = "https://app.nutmeg.com/client" r = s.get(url, headers=headers) soup = BeautifulSoup(r.content, 'html5lib') login_data['authenticity_token'] = soup.find('input', attrs={'name': 'authenticity_token'})['value'] r1 = s.post(url, data=login_data, headers=headers) r2 = s.get(url2, headers=headers) print(r2.content)any help would be much appreciated Thanks Just to add more information. Im trying to login to nutmeg account. https://app.nutmeg.com/auth/users/sign_in RE: Token and auth-token - fishhook - Jul-26-2019 Probably the site you are parsing is a kind of SPA application. This kind of sites don't return HTML as a response, they work over AJAX and receive only JSON. |