import hashlib from bs4 import BeautifulSoup import requests API_ENDPOINT = "https://btc.com/btc/block/" LAST_HEIGHT = 730445 seed = "" def get_block(height): global seed resp = requests.get(API_ENDPOINT + str(height)) soup = BeautifulSoup(resp.content, 'html.parser') block_hash = soup.find_all("div", {"class": "TopSummary_content__39aee"})[0].text assert block_hash.startswith("0000") h = hashlib.sha256(block_hash.encode("utf-8")).hexdigest() seed += h[0] next_height = int(h, 16) % LAST_HEIGHT return next_height next_height = 0 for _ in range(32): next_height = get_block(next_height) print(seed)