Skip to content

Instantly share code, notes, and snippets.

@Alchemyst0x
Last active March 17, 2023 18:32
Show Gist options
  • Save Alchemyst0x/a2d2c2e6ba19111a5f1fb0c65ff7bc5e to your computer and use it in GitHub Desktop.
Save Alchemyst0x/a2d2c2e6ba19111a5f1fb0c65ff7bc5e to your computer and use it in GitHub Desktop.
#!/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}")
@Alchemyst0x
Copy link
Author

Alchemyst0x commented Mar 17, 2023

Updated again, fixed to auto-resolve the buildID needed to complete the requests 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment