# #coding:utf-8 # import requests # from lxml import etree # class login(object): # def __init__(self): # self.headers={ # 'Referer': 'http://www.qixin.com/auth/login?return_url=%2F', # 'User - Agent': 'Mozilla / 5.0(Windows NT 6.1;Win64;x64) AppleWebKit / 537.36(KHTML, likeGecko) Chrome / 67.0.3396.99Safari / 537.36', # 'host':'Host: www.qixin.com' # } # # self.login_url='http://www.qixin.com/api/user/login' # self.post_url="http://www.qixin.com/api/user/session" # self.logined_url="http://www.qixin.com/api/user/settings/profile" # self.session=requests.Session() # def login(self,text,password): # data={ # 'acc': 'text', # 'pass': 'password', # 'captcha': '{isTrusted: true}', # 'keepLogin': 'false' # } # response = self.session.post(self.post_url, data=data, headers=self.headers) # if response.status_code == 200: # print 'ok' # # # # if __name__ == "__main__": # login = login() # login.login(text=18236531906,password=123456) # coding:utf-8 import requests headers={ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36', } def login(): session=requests.session() login_data={ 'acc': "18236531906", 'pass': "123456", 'captcha': '{isTrusted: true}', 'keepLogin': 'false' } afterurl="http://www.qixin.com/" login_url="http://www.qixin.com/api/user/login" session.post(login_url,data=login_data) login=session.post("http://www.qixin.com/api/user/login") response=session.get(afterurl,cookies=login.cookies,headers=headers) print (login_data) print (response.text) login()
执行结果如下:
标签:www,python,self,session,启信宝,qixin,com,login,模拟 From: https://www.cnblogs.com/lvjing/p/17756631.html