コード例 #1
0
ファイル: btce.py プロジェクト: cryschao/threebody
    def _withdraw(self, amount, target_address, coin):
        url = self._host + "/ajax/billing"
        data = {"act": "withdraw_coin/%s" % coin, "csrfToken": self.get_csrf_token()}
        res = self.session.post(url, data=data, **HTTP_ARGS)
        if not res.content:
            raise Exception(
                "Failed withdraw [amount: %s, target_address: %s, coin: %s, res: %s]"
                % (amount, target_address, coin, res.content)
            )

        inputs = get_input(res.content, type="hidden", name="id")
        token = inputs["token"]
        url = self._host + "/ajax/coins"
        data = {
            "act": "withdraw",
            "sum": str(amount),
            "address": target_address,
            "coin_id": str(coin),
            "token": token,
            "otp": str(get_totp(self._private_key, 1)),
            "csrfToken": self.get_csrf_token(),
        }
        res = self.session.post(url, data=data, **HTTP_ARGS)
        result = pq(res.text).find("h1").text()
        if result == "A letter with further instructions sent to your email!":
            logging.info("Withdraw[amount: %s, target_address: %s, coin: %s]", amount, target_address, coin)
        else:
            raise Exception(
                "Failed withdraw [amount: %s, target_address: %s, coin: %s, res: %s]"
                % (amount, target_address, coin, result)
            )
        self.auto_click_url()
コード例 #2
0
ファイル: btce.py プロジェクト: z3635363/threebody
    def _withdraw(self, amount, target_address, coin):
        url = self._host + '/ajax/billing'
        data = {
            'act': 'withdraw_coin/%s' % coin,
            'csrfToken': self.get_csrf_token()
        }
        res = self.session.post(url, data=data, **HTTP_ARGS)
        if not res.content:
            raise Exception(
                "Failed withdraw [amount: %s, target_address: %s, coin: %s, res: %s]"
                % (amount, target_address, coin, res.content))

        inputs = get_input(res.content, type="hidden", name='id')
        token = inputs['token']
        url = self._host + '/ajax/coins'
        data = {
            'act': "withdraw",
            'sum': str(amount),
            'address': target_address,
            'coin_id': str(coin),
            'token': token,
            'otp': str(get_totp(self._private_key, 1)),
            'csrfToken': self.get_csrf_token()
        }
        res = self.session.post(url, data=data, **HTTP_ARGS)
        result = pq(res.text).find('h1').text()
        if result == "A letter with further instructions sent to your email!":
            logging.info("Withdraw[amount: %s, target_address: %s, coin: %s]",
                         amount, target_address, coin)
        else:
            raise Exception(
                "Failed withdraw [amount: %s, target_address: %s, coin: %s, res: %s]"
                % (amount, target_address, coin, result))
        self.auto_click_url()
コード例 #3
0
ファイル: btce.py プロジェクト: hongmocai/threebody
    def _withdraw(self, amount, target_address, coin):
            url = self._host + '/ajax/billing'
            data = {'act': 'withdraw_coin/%s' % coin, 'csrfToken': self.get_csrf_token()}
            res = self.session.post(url, data=data, **HTTP_ARGS)
            if not res.content:
                raise Exception("Failed withdraw [amount: %s, target_address: %s, coin: %s, res: %s]" % (amount, target_address, coin, res.content))

            inputs = get_input(res.content, type="hidden", name='id')
            token = inputs['token']
            url = self._host + '/ajax/coins'
            data = {
                'act': "withdraw",
                'sum': str(amount),
                'address': target_address,
                'coin_id': str(coin),
                'token': token,
                'otp': str(get_totp(self._private_key, 1)),
                'csrfToken': self.get_csrf_token()
            }
            res = self.session.post(url, data=data, **HTTP_ARGS)
            result = pq(res.text).find('h1').text()
            if result == "A letter with further instructions sent to your email!":
                logging.info("Withdraw[amount: %s, target_address: %s, coin: %s]", amount, target_address, coin)
            else:
                raise Exception("Failed withdraw [amount: %s, target_address: %s, coin: %s, res: %s]" % (amount, target_address, coin, result))
            self.auto_click_url()
コード例 #4
0
    def _withdraw(self, amount, target_address, symbol):
            SYMBOL_BTC = 0
            OK_WITHDRAW_LTC_FEE = 0.001
            OK_WITHDRAW_BTC_FEE = 0.0001

            if amount < 0.01 or not target_address:
                raise WithdrawException('okcoin Withdraw amount too small require[%s] min[0.01]', amount)

            #span = res.find('#withdrawAddrSpan').text()
            #curr_withdraw_addr = span.split(u'\xa0\xa0')[1]
            #if curr_withdraw_addr != target_address:
            #    self._change_withdraw_addr(target_address)


            url = self._host + '/account/withdrawBtcSubmit.do?random=%s' % random.randint(0, 100)
            data = {
                'withdrawAddr' : target_address, 
                'withdrawAmount': '%.2f' % amount,
                'serviceChargeFee': symbol == SYMBOL_BTC and OK_WITHDRAW_BTC_FEE or OK_WITHDRAW_LTC_FEE,
                'tradePwd' : self.trade_pwd or self.password,
                'totpCode' : str(get_totp(self.private_key, 1)),
                'symbol': str(symbol),
                'phoneCode': '0',
            }
            res = self.s.post(url, data, **HTTP_ARGS)
            res_data = res.json()
            if res_data['resultCode'] == -4 or res_data['resultCode'] == -9:
                logging.warning('OK password fail %s', res_data)
                raise PasswordErrorException("Withdraw Password Error[amount: %s, target_address: %s, symbol: %s, res: %s]" % (amount, target_address, self.symbol, res.text))
            if res_data['resultCode'] == 3 or res_data['resultCode'] == 4:
                return self.auto_click_url()

            if res_data['resultCode'] == -20:
                logging.info("google psw used, sleep")
                time.sleep(30)
                raise Exception("Withdraw fail [data: %s, res: %s]" % (data, res.text))
            if res_data['resultCode'] == 0:
                return True
            else:
                time.sleep(1)
                raise WithdrawException("Withdraw fail [data: %s, res: %s]" % (data, res.text))
コード例 #5
0
ファイル: btce.py プロジェクト: cryschao/threebody
    def web_login(self):
        url = self._host
        res = self.session.get(url, **HTTP_ARGS)
        if res.text.find("Please wait...") != -1:
            new_cookie = get_in(res.text, 'document.cookie="a=', ";path=")
            self.session.cookies["a"] = new_cookie
            res = self.session.get(url, **HTTP_ARGS)
        if res.content and res.content.find("var auth_login = ''") == -1:
            logging.info("%s had login", self.name())
            return True

        url = self._host + "/ajax/login"
        data = "email=%s&password=%s&otp=-&PoW_nonce=" % (
            urllib.quote_plus(self._web_username),
            urllib.quote_plus(self._web_password),
        )
        res = self.session.post(url, data=data, **HTTP_ARGS)
        # {"success":1, "data":{"PoW":1,"work":{"target":3.1153781151209e+34,"data":"INZNJV92K196PR1Z9XGHVY20S3KQK0VIVZYSHO7C9TUKRUO9UYZETS1UNRREHC8I"}}}
        res_data = res.json()
        print res_data
        if res_data["success"]:
            if res_data["data"].get("login_success", 0) != 1:
                nonce = self.get_pow(res_data["data"]["work"]["target"], res_data["data"]["work"]["data"])
                # data = urllib.urlencode(data)
                data = "email=%s&password=%s&otp=%s&PoW_nonce=%s" % (
                    urllib.quote_plus(self._web_username),
                    urllib.quote_plus(self._web_password),
                    urllib.quote_plus(str(get_totp(self._private_key))),
                    nonce,
                )

                res = self.session.post(url, data=data, **HTTP_ARGS)
                res_data = res.json()
                print ">>>>", res_data
            if res_data["data"].get("login_success", 0) == 1:
                logging.info("%s login success", self.name())
                return True

        raise Exception("BTCE login fail")
コード例 #6
0
ファイル: btce.py プロジェクト: z3635363/threebody
    def web_login(self):
        url = self._host
        res = self.session.get(url, **HTTP_ARGS)
        if res.text.find('Please wait...') != -1:
            new_cookie = get_in(res.text, 'document.cookie="a=', ';path=')
            self.session.cookies['a'] = new_cookie
            res = self.session.get(url, **HTTP_ARGS)
        if res.content and res.content.find("var auth_login = ''") == -1:
            logging.info('%s had login', self.name())
            return True

        url = self._host + '/ajax/login'
        data = "email=%s&password=%s&otp=-&PoW_nonce=" % (urllib.quote_plus(
            self._web_username), urllib.quote_plus(self._web_password))
        res = self.session.post(url, data=data, **HTTP_ARGS)
        #{"success":1, "data":{"PoW":1,"work":{"target":3.1153781151209e+34,"data":"INZNJV92K196PR1Z9XGHVY20S3KQK0VIVZYSHO7C9TUKRUO9UYZETS1UNRREHC8I"}}}
        res_data = res.json()
        print res_data
        if res_data['success']:
            if res_data['data'].get('login_success', 0) != 1:
                nonce = self.get_pow(res_data['data']['work']['target'],
                                     res_data['data']['work']['data'])
                #data = urllib.urlencode(data)
                data = "email=%s&password=%s&otp=%s&PoW_nonce=%s" % (
                    urllib.quote_plus(self._web_username),
                    urllib.quote_plus(self._web_password),
                    urllib.quote_plus(str(get_totp(self._private_key))), nonce)

                res = self.session.post(url, data=data, **HTTP_ARGS)
                res_data = res.json()
                print '>>>>', res_data
            if res_data['data'].get('login_success', 0) == 1:
                logging.info("%s login success", self.name())
                return True

        raise Exception("BTCE login fail")