Exemplo n.º 1
0
 def ajax_php(self, step=1, params=None):
     """
     step=1:发送请求,校验参数w
     step=2:滑动滑块
     """
     if step == 1:
         params = {
             'gt': self.gt,
             'challenge': self.challenge,
             'lang': 'zh-cn',
             'w': get_full_page_w2(self.gt, self.challenge, self.s) + '1',
             'callback': 'geetest_' + now_str()
         }
     resp = fetch(self.session,
                  url=ajax_php_url,
                  headers=common_login_headers,
                  params=params)
     if resp is None:
         self.res = Resp.TIMEOUT
         return False
     if step != 1:
         res = json.loads(re.search(r'\((.*?)\)', resp.text, re.S).group(1))
         if res['data']['result'] != 'success':
             self.res = Resp.SLIDE_ERR
             return False
         self.validate = res['data']['validate']
         self.sec_code = self.validate + '|jordan'
     return True
Exemplo n.º 2
0
    def get_slide_images(self):
        """获取验证码图片的地址"""
        params = {
            'is_next': 'true',
            'type': 'slide3',
            'gt': self.gt,
            'challenge': self.challenge,
            'lang': 'zh-cn',
            'https': 'true',
            'protocol': 'https://',
            'offline': 'false',
            'product': 'popup',
            'api_server': 'captcha-api.com',
            'width': '100%',
            'callback': 'geetest_' + now_str()
        }
        resp = fetch(self.session,
                     url=get_php_url,
                     headers=common_login_headers,
                     params=params)
        if resp is None:
            self.res = Resp.TIMEOUT
            return False
        res = json.loads(re.search(r'\((.*?)\)', resp.text, re.S).group(1))

        # 获得滑动验证码图片的URL(带缺口+不带缺口)
        self.bg_url = prefix_url + res['data']['bg']
        self.full_bg_url = prefix_url + res['data']['fullbg']
        logger.info(
            f'滑动验证码图片,bg_url:{self.bg_url}, full_bg_url:{self.full_bg_url}')
        # 更新gt/challenge
        self.gt = res['data']['gt']
        self.challenge = res['data']['challenge']
        return True
Exemplo n.º 3
0
 def set_gt_challenge(self) -> bool:
     """发送网络请求,拿到gt和challenge"""
     params = dict(t=now_str())
     resp = fetch(self.session,
                  url=gt_register_url,
                  headers=common_login_headers,
                  params=params)
     if resp is None:
         logger.warning('无法获取gt/challenge...')
         self.res = Resp.TIMEOUT
         return False
     res = resp.json()
     logger.info(f'gt/challenge请求结果:{res}')
     self.gt, self.challenge = res['gt'], res['challenge']
     return True
Exemplo n.º 4
0
 def slide(self):
     """滑动滑块"""
     params = {
         'gt':
         self.gt,
         'challenge':
         self.challenge,
         'lang':
         'zh-cn',
         'w':
         get_slide_w(self.gt, self.challenge, get_s(), self.offset,
                     self.track),
         'callback':
         'geetest_' + now_str()
     }
     return self.ajax_php(step=2, params=params)
Exemplo n.º 5
0
 def get_php(self):
     """注册参数s:s经过多层加密拼接成w"""
     params = {
         'gt': self.gt,
         'challenge': self.challenge,
         'lang': 'zh-cn',
         'w': get_full_page_w1(self.gt, self.challenge, self.s),
         'callback': 'geetest_' + now_str()
     }
     resp = fetch(self.session,
                  url=get_php_url,
                  headers=common_login_headers,
                  params=params)
     if resp is None:
         logger.warning('无法注册参数s...')
         self.res = Resp.TIMEOUT
     return resp is not None