首页 > 移动平台 > 详细

爬中国联通

时间:2017-08-12 19:23:35      阅读:254      评论:0      收藏:0      [点我收藏+]
#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()

 

先登录再爬取。

技术分享

 

爬中国联通

原文:http://www.cnblogs.com/ydf0509/p/7351106.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!