Exemple #1
0
    def _captcha_handler(self, *args, **kwargs):

        session = args[0]
        html = args[1].text
        bs = BeautifulSoup(html)
        captcha_url = bs.find('img')['src']
        input_session_id = bs.find('input', {'name': 'sessionID'})['value']
        input_apply = bs.find('input', {'name': 'apply'})['value']
        input_referer = bs.find('input', {'name': 'referer'})['value']

        header = {'Referer': input_referer,
                  'User-Agent': 'Mozilla/5.0'}

        captcha_data = session.get(captcha_url, headers=header).content

        code = self.captcha_func(captcha_data)
        
        if handler:
            code = handler(captcha_data)
        else:
            captcha.show(captcha_data)
            code = raw_input('captcha >')
        
        url = 'http://www.xiami.com/alisec/captcha/tmdgetv3.php'
        data = {'code': code,
                'sessionID': input_session_id,
                'apply': input_apply,
                'referer': input_referer}

        ret = session.post(url, data=data, headers=header)
Exemple #2
0
    def _captcha_handler(self, *args, **kwargs):

        session = args[0]
        html = args[1].text
        bs = BeautifulSoup(html)
        captcha_url = bs.find('img')['src']
        input_session_id = bs.find('input', {'name': 'sessionID'})['value']
        input_apply = bs.find('input', {'name': 'apply'})['value']
        input_referer = bs.find('input', {'name': 'referer'})['value']

        header = {'Referer': input_referer, 'User-Agent': 'Mozilla/5.0'}

        captcha_data = session.get(captcha_url, headers=header).content

        code = self.captcha_func(captcha_data)

        if handler:
            code = handler(captcha_data)
        else:
            captcha.show(captcha_data)
            code = raw_input('captcha >')

        url = 'http://www.xiami.com/alisec/captcha/tmdgetv3.php'
        data = {
            'code': code,
            'sessionID': input_session_id,
            'apply': input_apply,
            'referer': input_referer
        }

        ret = session.post(url, data=data, headers=header)
Exemple #3
0
 def show_captcha(self, jpeg):
     import captcha
     captcha.show(jpeg)
     verifycode = raw_input('captcha > ')
     return verifycode
Exemple #4
0
 def _get_captcha(captcha_data):
     captcha.show(captcha_data)
     code = raw_input('captcha >')
     return code
Exemple #5
0
 def _get_captcha(captcha_data):
     captcha.show(captcha_data)
     code = raw_input('captcha >')
     return code