def get_account_info(self): """ Get account info. :return: dict """ if self._cli: cp.getting('Getting account info', inline=False) # get account info account_info = self._get_json({ 'action': 'getaccountinfo', 'token': self._token, 'format': 1, }) if self._cli: print(cp.Fore.GREEN + ' - Balance: %s' % account_info['Balance']) print(cp.Fore.LIGHTBLACK_EX + ' - Status: %s' % account_info['Status']) print(cp.Fore.LIGHTBLACK_EX + ' - UserLevel: %s' % account_info['UserLevel']) print(cp.Fore.LIGHTBLACK_EX + ' - MaxHold: %s' % account_info['MaxHold']) # print(xp.Fore.LIGHTBLACK_EX + ' - Discount: %s' % account_info['Discount']) # print(xp.Fore.LIGHTBLACK_EX + ' - Frozen: %s' % account_info['Frozen']) cp.fi() return account_info
def _get_token(self): """ Get token :return: str """ if self._cli: cp.getting('Getting token') token = self._get_result({ 'action': 'login', 'username': self._username, 'password': self._password, }) if self._cli: cp.value(token) return token
def get_a_mobile(self): """ Get a mobile phone number. :return: """ if self._cli: cp.getting('Getting a mobile phone number') self._mobile = self._get_result({ 'action': 'getmobile', 'token': self._token, 'itemid': self._item_id, 'excludeno': self._exclude_no, }) if self._cli: cp.value(self._mobile) return self._mobile
def random_a_proxy_dict_from_file(path_to_file: str): """ Random a proxy dict from a certain file, with verification. :param str path_to_file: /path/to/file :return: dict or None """ lines = file_fn.read_to_list(path_to_file) if lines: while len(lines) > 0: cp.getting('Random a proxy') # random _line = random.choice(lines) proxy_dict = line2dict(_line) # verify if proxy_dict: cp.wr('{host}:{port} '.format(host=proxy_dict['host'], port=proxy_dict['port'], )) cp.step(with_spaces=1) try: ip = ip_query(requests_proxies=dict2requests_proxies(proxy_dict)) if ip: cp.value(ip['ip'], inline=True) if ip['country']: cp.value(' ({})'.format(ip['country']), inline=True) cp.fx() return proxy_dict except Exception as e: cp.error('[proxy_fn] {}'.format(e)) lines.remove(_line) return None
def fake_name(gender: str = 'male', nation: str = 'us', cli: bool = False): """ Get a random user first/last name. :param str gender: Gender :param str nation: Nation :param bool cli: :return: str, str """ if cli: cp.getting('Random a name') r = random_an_user(gender=gender, nation=nation) name = r['name'] first_name = name['first'].strip().capitalize() last_name = name['last'].strip().capitalize() if cli: cp.value('{} {}'.format(first_name, last_name)) return first_name, last_name