def parse_get_accounts(self, all): if all: total_no = self.get_account_count() for i in tqdm.tqdm(range(int(total_no / 100))): dd = list(range(i * 100, (i + 1) * 100)) accounts = ['1.2.' + str(x) for x in dd] result = self.get_accounts(accounts) e = crawler_util.insertMongo(self.mongo_client, result) #print(result) else: dd = list(range(57800, 57890)) accounts = ['1.2.' + str(x) for x in dd] result = self.get_accounts(accounts) print(result) e = crawler_util.insertMongo(self.mongo_client, result)
def parse_account_balances(self, all, assets): if all: total_no = self.get_account_count() for i in tqdm.tqdm(range(total_no)): account = '1.2.' + str(i) result = self.get_account_balances(assets, account) for x in result: x['id'] = account x['time'] = datetime.now().strftime('%Y-%m-%d %H:%M:%S') e = crawler_util.insertMongo(self.mongo_client, result) #print(result) else: dd = list(range(57800, 57890)) accounts = ['1.2.' + str(x) for x in dd] for account in accounts: result = self.get_account_balances(assets, account) for x in result: x['id'] = account x['time'] = datetime.now().strftime('%Y-%m-%d %H:%M:%S') #print(result) e = crawler_util.insertMongo(self.mongo_client, result)
def saveBlock(self, block): """Insert a given parsed block into mongo.""" e = crawler_util.insertMongo(self.mongo_client, block) if e: self.insertion_errors.append(e)