Last active
March 17, 2023 18:32
-
-
Save Alchemyst0x/a2d2c2e6ba19111a5f1fb0c65ff7bc5e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import re | |
import requests | |
import json | |
# example of how to properly load the addresses | |
addresses = [ | |
"0x8e66f051a2b93d25857f203454aa14e81099a1c4", | |
"0x51264688eff18df8614ad4497d2a95d05ad63dfa", | |
"0xec69a813b10c18534ba9dfc4e0c6b424e0f13eb1", | |
] | |
url = "https://arbitrum.foundation/eligibility?address=" | |
response = requests.get(url) | |
html_content = response.content.decode("utf-8") | |
pattern = r'"buildId":"(.*?)"' | |
match = re.findall(pattern, html_content) | |
if match: | |
build_id = match[0] | |
print("Build ID: " + build_id) # prints the buildId value atop the output | |
else: | |
print("Unable to find buildId value in HTML content.") | |
for address in addresses: | |
url = f"https://arbitrum.foundation/_next/data/{build_id}/eligibility.json?address={address.lower()}" | |
response = requests.get(url) | |
if response.status_code == 200: | |
data = json.loads(response.text) | |
tokens = data["pageProps"]["eligibility"]["tokens"] | |
print(f"Tokens for {address}: {tokens:,}") | |
else: | |
print(f"Error fetching data for {address}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated again, fixed to auto-resolve the
buildID
needed to complete the requests 😄