from web3Tools import * initBolck = w3.eth.blockNumber - 10000 #topDexRouter #topFactory info = [] while initBolck < w3.eth.blockNumber : try: initBolck = initBolck +1 result = w3.new.getBlock(initBolck, True) transactions = result['transactions'] for transactionsI in transactions: function = transactionsI['input'][:10] if function in swapFunction: toAddress = transactionsI['to'].lower() if toAddress not in topDexRouter: topDexRouter.append(toAddress) try: factoryAddress = w3.dex.getFactory(toAddress).lower() if factoryAddress in topFactory: continue printTime('toAddress', toAddress) printTime('factoryAddress', factoryAddress) topFactory.append(factoryAddress) totalPair = w3.dex.getTotalPairV2(toAddress) printTime('totalPair', totalPair) data = {} data['router'] = toAddress data['factory'] = factoryAddress data['totalPair'] = totalPair info.append(data) except: continue except BaseException as err: time.sleep(20) printTime(info)