예제 #1
0
        def first_step():
            """获取一个cookie值"""

            url = (
                'http://www.cq.10086.cn/saturn/app?service=page/Home&listener'
                '=getCustInfo&CHAN_ID=E003&TELNUM=&?idsite=1&rec=1&url=https%3A%2F'
                '%2Fservice.cq.10086.cn%2FhttpsFiles%2FpageLogin.html&res=1440x900'
                '&col=24-bit&h=15&m=46&s=10&cookie=1&urlref=&rand=0'
                '.029307082742521917&pdf=1&qt=0&realp=0&wma=0&dir=0&fla=1&java=0'
                '&gears=0&ag=0&action_name=%2525E9%252587%25258D%2525E5%2525BA%252586'
                '%2525E7%2525A7%2525BB%2525E5%25258A%2525A8%2525E7%2525BD%252591'
                '%2525E4%2525B8%25258A%2525E8%252590%2525A5%2525E4%2525B8%25259A'
                '%2525E5%25258E%252585%25257C%2525E5%252585%252585%2525E5%252580'
                '%2525BC%2525EF%2525BC%25258C%2525E7%2525BC%2525B4%2525E8%2525B4'
                '%2525B9%2525EF%2525BC%25258C%2525E4%2525B8%25259A%2525E5%25258A'
                '%2525A1%2525E5%25258A%25259E%2525E7%252590%252586%2525EF%2525BC'
                '%25258C%2525E7%2525BD%252591%2525E4%2525B8%25258A%2525E8%252587'
                '%2525AA%2525E5%25258A%2525A9%2525E6%25259C%25258D%2525E5%25258A'
                '%2525A1%2525EF%2525BC%25258C%2525E7%2525A7%2525BB%2525E5%25258A'
                '%2525A8%2525E6%252594%2525B9%2525E5%25258F%252598%2525E7%252594'
                '%25259F%2525E6%2525B4%2525BB%2525E3%252580%252582')
            headers = {
                'Host':
                'service.cq.10086.cn',
                'Referer':
                'http://www.10086.cn/cq/index_230_230.html',
                'User-Agent': ('Mozilla/5.0 (Windows NT 6.1; Win64; x64) '
                               'AppleWebKit/537.36 (KHTML, like Gecko) '
                               'Chrome/57.0.2987.133 Safari/537.36')
            }
            res = url_requests.get(url, headers=headers)

            self.cookies.update(dict(res.cookies))
예제 #2
0
        def second_step(cookie):
            """根据first_step获取的cookie,获取第二个cookie并更新"""

            url = 'https://service.cq.10086.cn/ics'

            headers = {
                'Host':
                'service.cq.10086.cn',
                'Referer':
                'https://service.cq.10086.cn/httpsFiles/pageLogin.html',
                'User-Agent': ('Mozilla/5.0 (Windows NT 6.1; Win64; x64) '
                               'AppleWebKit/537.36 (KHTML, like Gecko) '
                               'Chrome/57.0.2987.133 Safari/537.36')
            }

            params = {
                'service': 'ajaxDirect/1/login/login/javascript/',
                'pagename': 'login',
                'eventname': 'checkIsLocalNumberNow',
                'cond_TELNUM': self.phone,
                'ajaxSubmitType': 'get',
                'ajax_randomcode': '20170508150704780.7728731616524849'
            }
            r = url_requests.get(url=url, params=params, headers=headers)

            self.cookies.update(dict(r.cookies))
예제 #3
0
        def updata1_cookies():
            """update cookies"""

            url = 'http://shop.10086.cn/i/v1/auth/loginfo?_=1493799199065'
            headers = {
                'Host':
                'shop.10086.cn',
                'Cache-Control':
                'no-store, must-revalidate',
                'pragma':
                'no-cache',
                'X-Requested-With':
                'XMLHttpRequest',
                'User-Agent':
                'Mozilla/5.0 (Windows NT 6.1; Win64; x64) '
                'AppleWebKit/537.36 (KHTML, like Gecko) '
                'Chrome/57.0.2987.133 Safari/537.36',
                'Referer':
                'http://shop.10086.cn/i/'
            }
            response = url_requests.get(url,
                                        headers=headers,
                                        cookies=self.cookies)

            self.cookies.update(dict(response.cookies))
예제 #4
0
        def get_info(phone):
            """获取用户信息"""

            url = ('http://shop.10086.cn/i/v1/cust/mergecust/%s?_'
                   '=1493799201153') % phone
            headers = {
                'Host':
                'shop.10086.cn',
                'Cache-Control':
                'no-store, must-revalidate',
                'pragma':
                'no-cache',
                'X-Requested-With':
                'XMLHttpRequest',
                'User-Agent':
                'Mozilla/5.0 (Windows NT 6.1; Win64; x64) '
                'AppleWebKit/537.36 (KHTML, like Gecko) '
                'Chrome/57.0.2987.133 Safari/537.36',
                'Referer':
                'http://shop.10086.cn/i/?f=home&welcome=1493796456510'
            }
            response = url_requests.get(url,
                                        headers=headers,
                                        cookies=self.cookies)
            profile = dict(json.loads(response.content))

            table = {}
            table['name'] = profile['data']['custInfoQryOut']['name']
            table['sex'] = ''
            table['address'] = profile['data']['custInfoQryOut']['address']
            table['cert_type'] = '身份证'
            table['cert_num'] = ''
            table['phone'] = profile['data']['custInfoQryOut']['contactNum']
            table['company'] = '中国移动'
            table['province'] = '重庆市'
            table['city'] = '重庆市'
            table['product_name'] = profile['data']['curPlanQryOut'][
                'curPlanName']
            table['level'] = profile['data']['custInfoQryOut']['starLevel']
            table['open_date'] = profile['data']['custInfoQryOut']['inNetDate']
            table['balance'] = ''
            if profile['data']['custInfoQryOut']['status'] == '00':
                table['user_valid'] = 1
            else:
                table['user_valid'] = 0

            return [table]
예제 #5
0
        def updata4_cookies():
            """"""

            url = ('http://shop.10086.cn/nresource/image/t_close.gif ')
            headers = {
                'Host':
                'shop.10086.cn',
                'User-Agent':
                'Mozilla/5.0 (Windows NT 6.1; Win64; x64) '
                'AppleWebKit/537.36 (KHTML, like Gecko) '
                'Chrome/57.0.2987.133 Safari/537.36',
                'Referer':
                'http://shop.10086.cn/i/?f=home&welcome=1493799181858'
            }
            response = url_requests.get(url,
                                        headers=headers,
                                        cookies=self.cookies)

            self.cookies.update(dict(response.cookies))
예제 #6
0
        def fifth_step(url, cookie):
            """用第4步请求得到的cookie和url,访问再更新一次cookie,该cookie应该可用与查询数据"""

            headers = {
                'Host':
                'login.10086.cn',
                'User-Agent':
                'Mozilla/5.0 (Windows NT 6.1; Win64; x64) '
                'AppleWebKit/537.36 (KHTML, like Gecko) '
                'Chrome/57.0.2987.133 Safari/537.36',
                'Referer':
                'https://service.cq.10086.cn/httpsFiles/pageLogin.html'
            }
            res3 = url_requests.get(url,
                                    headers=headers,
                                    cookies=cookie,
                                    allow_redirects=False)
            # print res3.cookies
            self.cookies.update(res3.cookies)
예제 #7
0
        def third_step(cookie):
            """用1,2步拿到的cookie去获取验证码图片"""

            url = ('https://service.cq.10086.cn/servlet/ImageServlet')
            headers = {
                'Host':
                'service.cq.10086.cn',
                'Referer':
                'https://service.cq.10086.cn/httpsFiles/pageLogin.html',
                'User-Agent': ('Mozilla/5.0 (Windows NT 6.1; Win64; x64) '
                               'AppleWebKit/537.36 (KHTML, like Gecko) '
                               'Chrome/57.0.2987.133 Safari/537.36')
            }
            res = url_requests.get(url, headers=headers, cookies=cookie)
            f = BytesIO(res.content)
            img = Image.open(f)
            # img.save('trainset/%s.png' % str(i))
            # img.show()
            return img
예제 #8
0
        def updata2_cookies():
            """"""

            url = ('https://login.10086.cn/SSOCheck.action?channelID=12003'
                   '&backUrl=http://shop.10086.cn/i/?f=home')
            headers = {
                'Host':
                'login.10086.cn',
                'User-Agent':
                'Mozilla/5.0 (Windows NT 6.1; Win64; x64) '
                'AppleWebKit/537.36 (KHTML, like Gecko) '
                'Chrome/57.0.2987.133 Safari/537.36',
                'Referer':
                'http://shop.10086.cn/i/'
            }
            response = url_requests.get(url,
                                        headers=headers,
                                        cookies=self.cookies)

            self.cookies.update(dict(response.cookies))
예제 #9
0
        def updata3_cookies():
            """"""

            url = ('http://shop.10086.cn/i/v1/auth/getArtifact?artifact'
                   '=e535b790be9c4b028aad1c122816413a&backUrl=http%3A%2F'
                   '%2Fshop.10086.cn%2Fi%2F%3Ff%3Dhome ')
            headers = {
                'Host':
                'shop.10086.cn',
                'User-Agent':
                'Mozilla/5.0 (Windows NT 6.1; Win64; x64) '
                'AppleWebKit/537.36 (KHTML, like Gecko) '
                'Chrome/57.0.2987.133 Safari/537.36',
                'Referer':
                'http://shop.10086.cn/i/'
            }
            response = url_requests.get(url,
                                        headers=headers,
                                        cookies=self.cookies)

            self.cookies.update(dict(response.cookies))