Skip to content

Instantly share code, notes, and snippets.

@Alchemyst0x
Last active March 17, 2023 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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

This has to be updated every time the script location changes; ie. just now it was:

https://arbitrum.foundation/_next/data/wX04UisPEjc-aIaKHSFBM/eligibility.json?address=

And updated to:

https://arbitrum.foundation/_next/data/E53Lyb8HtXazUfcS1qEax/eligibility.json?address=

I attempted to scrape the new directory name, but I am not great with that stuff in particular, so didn't find a working solution other than manually grabbing the new string value for the directory any time a new build is pushed on their website.

Other changes:

  • Fixed addresses resulting incorrectly with 0 value for claimable tokens, due to the way the addresses need to be formatted. Thanks to Fantasy for this fix, changing the address to lowercase format to parse correctly.
  • Likewise credited to Fantasy - simple modification to add a ',' to thousandths output of tokens amount.

@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