#coding=utf8 import requests class ChinaUnicom(object): headerx={‘User-Agent‘:‘Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36‘} login_url=‘https://uac.10010.com/portal/Service/MallLogin‘ info_url=‘https://uac.10010.com/cust/infomgr/anonymousInfoAJAX‘ def __init__(self,phone,server_passwd): self.ss=requests.session() self.phone=phone self.server_passwd=server_passwd def login(self): datax={ ‘callback‘:‘jQuery17208315958887266249_1502520335284‘, ‘req_time‘:‘1502520347528‘, ‘redirectURL‘:‘http://www.10010.com‘, ‘userName‘:self.phone, ‘password‘:self.server_passwd, ‘pwdType‘:‘01‘, ‘productType‘:‘01‘, ‘redirectType‘:01, ‘rememberMe‘:1, ‘_‘:‘1502520347531‘, } self.ss.get(self.login_url,params=datax,headers=self.headerx) ##可以不要真实浏览器ua def get_infomgrInit(self): ‘‘‘获取个人信息‘‘‘ resp=self.ss.post(self.info_url) return resp.content if __name__=="__main__": cu=ChinaUnicom(1314880xxxx,37xxxx) cu.login() print cu.get_infomgrInit()
先登录再爬取。
时间: 2024-10-13 12:02:17