I am playing with the requests module in python and I am stuck with a problem.
I use requests to login on a website (http://coinplants.com) using the Session class. After the login I am trying to read the html of the page and I realized that the response object shows only the html body with it's content but not the html head. I would like to get the html head with the meta tags. Any idea what I am doing wrong?
s = requests.Session()
r = s.post('http://coinplants.com', data=postData)
print r.text
Thanks in advance :)
LOGIN
To scrap the authenticity token I use BeautifulSoup
soup = BeautifulSoup(r.text, 'lxml')
finding = soup.find('input', {'name' : 'authenticity_token'})
postData = {'utf8' : '%E2%9C%93', 'authenticity_token' : '',
'account[email]' : self.username, 'account[password]' : self.password,
'account[remember_me]' : '0', 'commit' : 'Log+in'}
postData['authenticity_token'] = finding['value']
r = s.post('http://coinplants.com/accounts/sign_in', data=postData)
Solution
Ok, I found a solution to my problem. I have no idea why the session doesn't give me the whole html content. I took the cookie from the session object and added it to a request object:
cookies = {'_faucet:session' : s.cookies['_faucet_session']}
r = requests.get('http://coinplants.com', cookies=cookies)
print r.text
s is the session object. When I print the text of the response object it shows me the whole html content, including head tag. If someone knows why the session object is not showing it, please let me know :)