# !/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
import urllib
import cookielib
import json
import httplib
import re
import requests
s=requests.session()
print s.headers
url = "https://licai.yingyinglicai.com/user/login.htm"
headers={
    'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:54.0) Gecko/20100101 Firefox/54.0',
    'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
    'Host': 'licai.yingyinglicai.com',
    'Referer': 'https://licai.yingyinglicai.com/index.htm',
}
r = s.get(url,headers=headers)
r=r.text
#print s
print type(r)
r = r.encode('unicode-escape')
print type(r)
p = re.compile('.*token"\s+value="(.*?)".*')
m = p.match(r)
token = m.group(1)
print token

login_url='https://licai.yingyinglicai.com/user/loginByPwd.do'
data = {'cell': '18072722237', 'password': 'xx', 'token': token}
#data = urllib.urlencode(data)
response = s.post(login_url, data=data,headers=headers)
print  response
print response.status_code
print response.content
url='http://licai.yingyinglicai.com/index.htm'
r= s.get(url,headers=headers)
r = r.text
print r
print type(r)