#coding:utf-8
import requests
class Tb:
def __init__(self, username, password):
self.s = requests.session()
self.username = username
self.password = password
self.headers = {
'origin': 'https://login.taobao.com',
'accept-language': 'zh-CN,zh;q=0.8',
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
'referer': 'https://login.taobao.com/member/login.jhtml?',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36',
}
def get_login_data(self):
data = {
'TPL_username': self.username,
'TPL_password': self.password,
}
self.s.post('https://login.taobao.com/member/login.jhtml', data=data, headers=self.headers)
url = 'https://i.taobao.com/user/baseInfoSet.htm?spm=a1z02.1.972272805.d4912005.37014ebaxw0wad'
p = self.s.get(url)
if '我的淘宝 - 个人资料' in p.text:
print('成功登陆')
def main(self):
self.get_login_data()
t = Tb('账号', '密码')
t.main()