示例#1
0
    def getbasic_msgcode(self):
        url = "http://service.js.10086.cn/my/sms.do"
        form_data = {"busiNum": "MY_GRZLGL_LOGIN"}
        self.headers[
            "Referer"] = "http://service.js.10086.cn/my/MY_GRZLGL.html"
        self.headers["Origin"] = "http://service.js.10086.cn"
        self.headers["Host"] = "service.js.10086.cn"

        options = {
            'method': 'post',
            'url': url,
            'form': form_data,
            'params': None,
            'cookies': self.cookies,
            'headers': self.headers,
            'timeout': 30
        }
        response = Request.basic(options)
        if response.status_code == 200:
            result = json.loads(response.content)
            if result['success'] == True:
                return return_result(code=2000,
                                     data=None,
                                     desc=u"获取用户基本信息短信验证码成功!!!")
            else:
                return return_result(code=4000,
                                     data=None,
                                     desc=u"获取用户基本短信验证码请求失败!!!")
        else:
            return return_result(code=4000,
                                 data=None,
                                 desc=u"手机号为{}获取用户基本短信验证码请求失败!!!".format(
                                     self.phone_num))
示例#2
0
 def LoingVsy(self):
     url = "http://service.js.10086.cn/actionDispatcher.do"
     form_data = {
         'userLoginTransferProtocol': 'https',
         'redirectUrl': 'my/MY_QDCX.html?t=1490234778114#home',
         'reqUrl': 'login',
         'busiNum': 'LOGIN',
         'operType': '0',
         'passwordType': '1',
         'isSavePasswordVal': '0',
         'isSavePasswordVal_N': '1',
         'currentD': '1',
         'loginFormTab': '#home',
         'loginType': '1',
         'phone-login': '******',
         'mobile': '18800566440',
         'city': 'NJDQ',
         'password': '******',
         'verifyCode': '',
     }
     form_data['mobile'] = self.phone_num
     form_data['password'] = self.password
     self.headers['Origin'] = 'http://service.js.10086.cn'
     self.headers['Host'] = 'service.js.10086.cn'
     self.headers[
         "Referer"] = 'http://service.js.10086.cn/login.html?url=http://service.js.10086.cn/index.html'
     options = {
         'method': 'post',
         'url': url,
         'form': form_data,
         'params': None,
         'cookies': self.cookies,
         'headers': self.headers,
         'timeout': 30
     }
     response = Request.basic(options=options)
     if response:
         if response.status_code == 200:
             if 'login.html' not in response.content:
                 #self.cookies=dict_from_cookiejar(response.cookies)
                 self.cookies = response.cookies
                 return return_result(code=2000,
                                      data=self.cookies,
                                      desc=u"登录成功!!!")
             else:
                 return return_result(
                     code=4600,
                     data="None",
                     desc=u"phone:{}password:{}用户名或密码错误".format(
                         self.phone_num, self.password))
         else:
             return return_result(code=4000,
                                  data="None",
                                  desc=u"{}登录请求网络错误".format(self.phone_num))
     else:
         return_result(code=4000,
                       data="None",
                       desc=u"{}登录请求网络错误".format(self.phone_num))
示例#3
0
    def getphonemsgfirst(self, msgnum, dict_param):
        url = "http://service.js.10086.cn/my/actionDispatcher.do"
        form_data = {
            'reqUrl': 'MY_QDCXQueryNew',
            'busiNum': 'QDCX',
            'queryMonth': dict_param['mon'],
            'queryItem': '1',
            'qryPages': '',
            'qryNo': '1',
            'operType': '3',
            'queryBeginTime': dict_param['fday'],
            'queryEndTime': dict_param['lday'],
            'smsNum': msgnum,
            'confirmFlg': '1'
        }
        self.headers[
            "Referer"] = "http://service.js.10086.cn/my/MY_QDCX.html?t=1490249727911"
        self.headers["Origin"] = "Origin: http://service.js.10086.cn"
        self.headers["Host"] = "service.js.10086.cn"

        options = {
            'method': 'post',
            'url': url,
            'form': form_data,
            'params': None,
            'cookies': self.cookies,
            'headers': self.headers,
            'timeout': 30
        }
        response = Request.basic(options)
        if response:
            if response.status_code == 200:
                results_dict = json.loads(response.content)
                if results_dict['success'] == True:
                    self.Parsecall(results_dict, dict_param['mon'])
                    return return_result(code=2000,
                                         data=None,
                                         desc=u"通话记录首次请求成功!!!")

                elif results_dict['success'] == False:
                    return return_result(code=4610,
                                         data=None,
                                         desc=u"短信验证码错误!!!")
            else:
                return return_result(code=4000,
                                     data=None,
                                     desc=u"{"
                                     u"}用户通话记录首次请求失败!!!".format(
                                         self.phone_num))
        else:
            return return_result(code=4000,
                                 data=None,
                                 desc=u"{"
                                 u"}用户通话记录首次请求失败!!!".format(self.phone_num))
示例#4
0
    def getResult(self):
        Crawlinfo.__result_data['t_operator_user'] = [Crawlinfo.__user_dict]
        Crawlinfo.__result_data[
            't_operator_call'] = Crawlinfo.__t_operator_call
        Crawlinfo.__result_data[
            't_operator_note'] = Crawlinfo.__t_operator_note

        #如果定义的两个列表都为空说明数据解析了6次对应6个月的数据都爬取了,否则数据不全
        if Crawlinfo.__judge_clist == [] and Crawlinfo.__judge_nlist == []:
            return return_result(code=2000,
                                 data=Crawlinfo.__result_data,
                                 desc=u"流程成功全部有数据!!!")
        else:
            return return_result(code=2001,
                                 data=Crawlinfo.__result_data,
                                 desc=u"流程成功部分有数据!!!")
示例#5
0
 def getphonemsgothermonth(self, dict_param):
     url = "http://service.js.10086.cn/my/actionDispatcher.do"
     form_data = {
         'reqUrl': 'MY_QDCXQueryNew',
         'busiNum': 'QDCX',
         'queryMonth': dict_param['mon'],
         'queryItem': '1',
         'qryPages': '1:1002:-1',
         'qryNo': '1',
         'operType': '3',
         'queryBeginTime': dict_param['fday'],
         'queryEndTime': dict_param['lday']
     }
     options = {
         'method': 'post',
         'url': url,
         'form': form_data,
         'params': None,
         'cookies': self.cookies,
         'headers': self.headers,
         'timeout': 30
     }
     response = Request.basic(options)
     if response:
         if response.status_code == 200:
             results = json.loads(response.content)
             if results['success'] == True:
                 self.Parsecall(results, dict_param['mon'])
             else:
                 msg_desc = u'{}月份的通话记录获取失败'.format(dict_param['mon'])
                 print msg_desc
                 return return_result(code=4000, data=None, desc=msg_desc)
         else:
             return return_result(code=4000,
                                  data=None,
                                  desc=u"{},"
                                  u"{}月份的通话记录请求失败!!!".format(
                                      self.phone_num, dict_param['mon']))
     else:
         return return_result(code=4000,
                              data=None,
                              desc=u"{},"
                              u"{}月份的通话记录请求失败!!!".format(
                                  self.phone_num, dict_param['mon']))
示例#6
0
    def getmsgcode(self):
        from requests import cookies
        url = "http://service.js.10086.cn/my/sms.do"
        form_data = {"busiNum": "QDCX"}
        self.headers[
            "Referer"] = "http://service.js.10086.cn/my/MY_QDCX.html?t=1490249727911"
        self.headers["Origin"] = "http://service.js.10086.cn"
        self.headers["Host"] = "service.js.10086.cn"

        options = {
            'method': 'post',
            'url': url,
            'form': form_data,
            'params': None,
            'cookies': self.cookies,
            'headers': self.headers,
            'timeout': 30
        }
        response = Request.basic(options)
        if response:
            if response.status_code == 200:
                result_dict = json.loads(response.content)
                if result_dict['success'] == True:
                    self.cookies = cookies.merge_cookies(
                        self.cookies, response.cookies)
                    self.cookies = dict_from_cookiejar(self.cookies)
                    return return_result(code=2000,
                                         data=self.cookies,
                                         desc=u"获取短信验证码成功")
                else:
                    return return_result(code=4000,
                                         data=None,
                                         desc=u"获取短信验证码失败!!!")
            else:
                return return_result(code=4000,
                                     data=None,
                                     desc=u"{"
                                     u"}用户短信验证码请求失败!!!".format(self.phone_num))
        else:
            return return_result(code=4000,
                                 data=None,
                                 desc=u"{"
                                 u"}用户短信验证码请求失败!!!".format(self.phone_num))
示例#7
0
    def getMyproduct(self):
        productstr = ''
        url = "http://service.js.10086.cn/my/MY_WDYW.html"
        self.headers["Referer"] = "http://service.js.10086.cn/my/MY_WDYW.html"
        self.headers["Host"] = "service.js.10086.cn"
        options = {
            'method': 'post',
            'url': url,
            'form': None,
            'params': None,
            'cookies': self.cookies,
            'headers': self.headers,
            'timeout': 30
        }
        response = Request.basic(options)
        if response.status_code == 200:
            bsoup = BeautifulSoup(response.content)

            script_results = bsoup.find_all("script")

            for i in range(8, len(script_results)):

                script_product = str(script_results[i])

                re_result = re.search(r'({.*})', script_product).group(1)

                json_result = json.loads(re_result)

                if 'resultObj' in json_result:
                    result_dict = json_result['resultObj']
                    #获取余额信息
                    if "accountBalance" in result_dict:
                        Crawlinfo.__user_dict['balance'] = json_result[
                            'resultObj']["accountBalance"]

                    if 'KEY_bizList' in result_dict:
                        result_list = json_result['resultObj']['KEY_bizList']
                        for i in range(len(result_list)):
                            productstr += result_list[i]["pkgName"] + ','
                        Crawlinfo.__user_dict['product_name'] = productstr[:-1]
            return return_result(code=2000, data=None, desc=u"获取用户套餐数据成功")
        else:
            return return_result(code=4000, data=None, desc=u"用户套餐数据请求失败.....")
示例#8
0
    def get_duanxin(self, dict_param):
        url = "http://service.js.10086.cn/my/actionDispatcher.do"
        form_data = {
            'reqUrl': 'MY_QDCXQueryNew',
            'busiNum': 'QDCX',
            'queryMonth': dict_param['mon'],
            'queryItem': '6',
            'qryPages': '6:1006:-1',
            'qryNo': '1',
            'operType': '3',
            'queryBeginTime': dict_param['fday'],
            'queryEndTime': dict_param['lday']
        }
        self.headers["Referer"] = "http://service.js.10086.cn/my/MY_QDCX.html"
        self.headers["Origin"] = "http://service.js.10086.cn"
        self.headers["Host"] = "service.js.10086.cn"

        options = {
            'method': 'post',
            'url': url,
            'form': form_data,
            'params': None,
            'cookies': self.cookies,
            'headers': self.headers,
            'timeout': 30
        }
        response = Request.basic(options)
        if response.status_code == 200:
            results = json.loads(response.content)
            if results['success'] == True:
                self.ParseNote(results, dict_param['mon'])
            else:
                msg_desc = u'{}月份的短信记录获取失败'.format(dict_param['mon'])
                print msg_desc
                return return_result(code=4000, data=None, desc=msg_desc)
        else:
            return return_result(code=4000,
                                 data=None,
                                 desc=u"{"
                                 u"}月份的短信记录请求失败!!!".format(dict_param['mon']))
示例#9
0
    def get_basicInfo(self):
        import time
        timelist = []
        #http://service.js.10086.cn/my/MY_GRZLGL.html
        #http://service.js.10086.cn/my/MY_GRZLGL.html
        url = "http://service.js.10086.cn/my/MY_GRZLGL.html"
        self.headers[
            "Referer"] = "http://service.js.10086.cn/my/MY_GRZLGL.html"
        self.headers["Host"] = "service.js.10086.cn"

        options = {
            'method': 'get',
            'url': url,
            'form': None,
            'params': None,
            'cookies': self.cookies,
            'headers': self.headers,
            'timeout': 30
        }
        response = Request.basic(options)
        if response.status_code == 200:
            htmlresult = response.content
            # 获取基本信息
            bsoup = BeautifulSoup(response.content)
            script_result = bsoup.find_all("script")

            results = str(script_result[-3])

            re_result = re.search(r'({.*})', results).group(1)
            try:
                dict_result = json.loads(re_result)
                Crawlinfo.__user_dict['name'] = dict_result["resultObj"][
                    'kehuName']
                # 手机号码
                Crawlinfo.__user_dict['phone'] = dict_result["resultObj"][
                    "shoujihaoma"]
                # 用户状态
                Crawlinfo.__user_dict['user_valid'] = dict_result["resultObj"][
                    "yonghuState"]
                # 入网时间
                timestr = dict_result["resultObj"]["ruwangAt"]
                timelist.append(timestr[:4])
                timelist.append(timestr[4:6])
                timelist.append(timestr[6:8])
                ruwangAt = '-'.join(timelist)
                Crawlinfo.__user_dict['open_date'] = ruwangAt
                # 客户星级
                Crawlinfo.__user_dict['level'] = dict_result["resultObj"][
                    "kehuxingji"]
            except Exception as e:
                print e
                return return_result(code=4000, data=None, desc=u"用户基本信息解析错误")

            #调用百度接口获取用户手机号归属定等信息
            phoneinfo = get_phone_attr(self.phone_num)
            if phoneinfo['code'] == 2000:
                Crawlinfo.__user_dict['province'] = phoneinfo['data'][
                    'province']
                Crawlinfo.__user_dict['city'] = phoneinfo['data']['city']
                Crawlinfo.__user_dict['company'] = phoneinfo['data']['company']
            else:
                return phoneinfo
                Crawlinfo.__user_dict['cert_type'] = ''
                Crawlinfo.__user_dict['sex'] = ''
                Crawlinfo.__user_dict['address'] = ''
                Crawlinfo.__user_dict['cert_num'] = ''
            return return_result(code=2000, data=None, desc=u"获取用户基本信息成功")
        else:
            return return_result(code=4000,
                                 data=None,
                                 desc=u"{}用户基本信息请求失败".format(self.phone_num))