Exemplo n.º 1
0
 def __init__(self, Ppool):
     self.logger = class_logger.getLogger('UserPool')
     self.Proxypool = Ppool
     self.rkclient = rk.RClient(rk_username, rk_pwd)
     self.logger.info('Initing System')
     self.dbc = class_MongoDB.MongoClient(class_config.Mongo_uri,class_logger.getLogger('MongoDB_Users'),'JD')
     self.dbc.setUnique('Users','username')
Exemplo n.º 2
0
 def ruokuai_image(self):
     url = 'https://kyfw.12306.cn/passport/captcha/captcha-image?login_site=E&module=login&rand=sjrand&0.5326066130802138'
     headers = {'referer': 'https://kyfw.12306.cn/otn/login/init'}
     r = self.s.get(url, headers=headers)
     img = r.content
     rc = rk.RClient('mumuloveshine', 'mumu2018', '7545',
                     'df49bdfd6416475181841e56ee1dc769')
     answer = rc.rk_create(img, 6113)
     return answer['Result']
Exemplo n.º 3
0
def get_verifycode(verifycode_url):
    url = 'https://passport.jd.com/uc/showAuthCode?r='
    resp = requests.get(url)
    if '\"verifycode\":true' in resp.text:
        for i in range(2):
            resp = requests.get(
                'https:%s&yys=%d' % (verifycode_url.replace(
                    '&', '&'), int(round(time.time() * 1000))),
                headers={
                    'Referer':
                    'https://passport.jd.com/new/login.aspx?ReturnUrl=https%3A%2F%2Fwww.jd.com%2F'
                })
        logger.info('send image to rk')
        rc = rk.RClient('15974253250', '1qaz2wsx', '78409',
                        'e024badb361646e1a38a2afca8cf23f6')
        result = rc.rk_create(resp.content, 3000)
        logger.debug('rk=>' + json.dumps(result))
        if result and result['Result']:
            logger.info('verify code =>' + result['Result'])
            return result['Result']
    else:
        return None
Exemplo n.º 4
0
    def login(self,
              username,
              password,
              rk_username='******',
              rk_password='******'):
        s = requests.session()
        m = hashlib.md5()
        headers = {
            'User-Agent':
            'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36'
        }
        r = 0
        html = s.get('https://passport.jd.com/new/login.aspx',
                     headers=headers).text
        self.logger.info('登录页面加载完毕')
        # uuid
        property_list_reg = '//*[@id="uuid"]'
        tree = etree.HTML(html)
        property_lst = tree.xpath(property_list_reg)
        if len(property_lst) >= 1:
            uuid = property_lst[0].attrib['value']

        cs = s.cookies.get_dict()
        for tt in cs.keys():
            if tt != 'qr_t' and tt != 'alc':
                _t = tt
                # print(_t)

        imgcode = 'null'
        url = 'https://passport.jd.com/uc/showAuthCode?r=' + str(
            random.random()) + '&version=2015'
        html = s.get(url, headers=headers)
        self.logger.info('判断是否需要验证码')
        if 'false' in html:
            self.logger.info('不需要验证码')
        else:
            # 获取验证码
            self.logger.info('开始获取验证码')
            url = 'https://authcode.jd.com/verify/image?a=1&acid=' + uuid + '&uid=' + uuid + '&yys=' + str(
                int(time.time() * 1000))
            # print(url)
            c = ''
            for k in s.cookies:
                c = c + k.name + '=' + k.value + ';'
            # print(c)
            h = headers
            h['accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8'
            h['Referer'] = 'https://passport.jd.com/uc/login?ltype=logout'
            h['Cache-Control'] = 'no-cache'
            h['Accept-Encoding'] = 'gzip, deflate, br'
            h['Accept-Language'] = 'zh-CN,zh;q=0.8'
            img = s.get(url, headers=h)

            im = img.content
            self.logger.info('提交RK')
            imgcode = rk.RClient(rk_username,
                                 rk_password).rk_create(im, 3040)['Result']

        eid = ''.join(random.sample(string.ascii_letters, 10)).upper()
        eid = eid.join(random.sample(string.ascii_letters, 9)).upper() + '1'

        m.update(str(int(time.time() * 1000)).encode())
        fp = m.hexdigest()

        data = {
            'uuid': uuid,
            'eid': eid,
            'fp': fp,
            '_t': _t,
            'loginType': 'c',
            'loginname': username,
            'nloginpwd': password,
            'chkRememberMe': '',
            'authcode': imgcode
        }
        self.logger.info('提交登录')
        url = 'https://passport.jd.com/uc/loginService?uuid=' + uuid + '&r=' + str(
            random.random()) + '&version=2015'
        h = s.post(url=url, data=data)

        if 'success' in h.text:
            c = ''
            for k in s.cookies:
                c = c + k.name + '=' + k.value + ';'
            ret = {
                'state': 200,
                'msg': '登陆成功',
                'cookies': base64.b64encode(c.encode('utf-8'))
            }
            self.logger.info('登陆成功')

            return ret
        else:
            ret = {'state': 201, 'msg': '登陆失败', 'cookies': 'null'}
            self.logger.info('登陆失败')
            return ret
Exemplo n.º 5
0
def check_ip(name):
    headers = {
        'Connection': 'keep-alive',
        'Upgrade-Insecure-Requests': '1',
        'User-Agent':
        'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36',
        'Accept':
        'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
        'Referer':
        'http://www.miitbeian.gov.cn/commons/left.jsp;jsessionid=W82S7WH28XCqxxT105quV3E6HrARNXaaI47UDne5gzUq1sq7Tjv3^!1316315234',
        'Accept-Encoding': 'gzip, deflate',
        'Accept-Language': 'zh-CN,zh;q=0.9',
    }

    s = requests.Session()
    response1 = s.get(
        'http://www.miitbeian.gov.cn/icp/publish/query/icpMemoInfo_showPage.action',
        headers=headers)
    response2 = s.get("http://www.miitbeian.gov.cn/getVerifyCode?" +
                      str(random.randint(0, 100)),
                      headers=headers)

    # with open("capcha.gif",'wb') as f:
    #     f.write(response2.content)

    ruokuai = rk.RClient(user, password)
    yzm_request = ruokuai.rk_create(response2.content, 3060)
    yzm = yzm_request['Result']
    data = {'validateValue': yzm}
    response3 = s.post(
        "http://www.miitbeian.gov.cn/common/validate/validCode.action",
        data=data,
        headers=headers)

    data1 = [
        ('siteName', ''),
        ('condition', '1'),
        ('siteDomain', name),
        ('siteUrl', ''),
        ('mainLicense', ''),
        ('siteIp', ''),
        ('unitName', ''),
        ('mainUnitNature', '-1'),
        ('certType', '-1'),
        ('mainUnitCertNo', ''),
        ('verifyCode', yzm),
    ]

    response4 = s.post(
        'http://www.miitbeian.gov.cn/icp/publish/query/icpMemoInfo_searchExecute.action',
        headers=headers,
        data=data1)
    html = response4.text
    data = etree.HTML(html)
    try:
        content = data.xpath('//td[@class="bxy"]/text()')
    except IndexError:
        print("输入的网址错误,请检查后再输入!!!")
        main()
    name = content[1]
    type = content[2]
    num = content[3]
    hostname = content[4]
    ip = content[5]
    time = content[6]
    print('--------------------------------')
    print('主办单位名称:', name)
    print('主办单位性质:', type)
    print('网站备案/许可证号:', num)
    print('网站名称:', hostname)
    print('网站首页网址:', ip)
    print('审核时间:', time)
    print('--------------------------------')
Exemplo n.º 6
0
def code():
    rc = rk.RClient('1290259791', 'hu1997', '101476',
                    'a0546e49605d427790704b48b0221243')
    im = open('image.png', 'rb').read()
    code = rc.rk_create(im, 3040)
    return code.get('Result')