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}") |
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
This has to be updated every time the script location changes; ie. just now it was:
And updated to:
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: