Last active
December 7, 2024 12:53
-
-
Save ChypherC0d3/0716bf04e8362bf48ba265b4d3edecd6 to your computer and use it in GitHub Desktop.
RichestMultiChainWallets.ipynb
This file contains 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
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"name": "RichestMultiChainWallets.ipynb", | |
"provenance": [], | |
"collapsed_sections": [], | |
"authorship_tag": "ABX9TyPzqVMihITyAUXKq4ecmxWW", | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
}, | |
"language_info": { | |
"name": "python" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/CynegeticIO/0716bf04e8362bf48ba265b4d3edecd6/richestmultichainwallets.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"########################################################################################################\n", | |
"############################ GET TOP ACCOUNTS IN A BLOCKCHAINs #########################################\n", | |
"########################################################################################################" | |
], | |
"metadata": { | |
"id": "jlTZGY7JBAiK" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "noWPlq5pRVCY", | |
"outputId": "7c74e672-db2c-4c48-fb52-1ebeff558b1e" | |
}, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"name": "stdout", | |
"text": [ | |
"Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n", | |
"Requirement already satisfied: beautifulsoup4==4.6.3 in /usr/local/lib/python3.7/dist-packages (4.6.3)\n" | |
] | |
} | |
], | |
"source": [ | |
"pip install beautifulsoup4==4.6.3" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"import csv\n", | |
"import sys\n", | |
"import datetime\n", | |
"import requests\n", | |
"from time import sleep\n", | |
"from bs4 import BeautifulSoup" | |
], | |
"metadata": { | |
"id": "2ErPw0rpSfn1" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"%%time\n", | |
"\n", | |
"# 10 chains - 25' execution time in minutes\n", | |
"\n", | |
"import pandas as pd\n", | |
"import numpy as np\n", | |
"from bs4 import BeautifulSoup as soup\n", | |
"from urllib.request import Request, urlopen\n", | |
"import time\n", | |
"\n", | |
"bsc = 'https://bscscan.com/accounts/'\n", | |
"arb = 'https://arbiscan.io/accounts/'\n", | |
"eth = 'https://etherscan.io/accounts/'\n", | |
"ftm = 'https://ftmscan.com/accounts/'\n", | |
"avax = 'https://snowtrace.io/accounts/'\n", | |
"celo = 'https://celoscan.io/accounts/' \n", | |
"matic = 'https://polygonscan.com/accounts/'\n", | |
"moon = 'https://moonscan.io/accounts/'\n", | |
"opt = 'https://optimistic.etherscan.io/accounts/'\n", | |
"cro = 'https://cronoscan.com/accounts/'\n", | |
"\n", | |
"chain = [bsc, arb, eth, ftm, avax, celo, matic, moon, opt, cro]\n", | |
"addr = []\n", | |
"\n", | |
"for w in range(0,len(chain)):\n", | |
" time.sleep(0.5)\n", | |
" for i in range(1,101):\n", | |
" url = (chain[w]+str(i)+\"?ps=100\")\n", | |
" req = Request(url, headers={'User-Agent': 'Mozilla/5.0'})\n", | |
" webpage = urlopen(req).read()\n", | |
" html = soup(webpage, \"html.parser\")\n", | |
" fundamentals = pd.read_html(str(html))\n", | |
" time.sleep(1)\n", | |
" for j in range(0,100):\n", | |
" addr.append(fundamentals[0].Address[j])\n", | |
"\n", | |
"print(len(list(set(addr))))" | |
], | |
"metadata": { | |
"id": "K7l3cFkqZ--z", | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"outputId": "7dc92d29-b768-46f9-fd99-090dbec7701b" | |
}, | |
"execution_count": null, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"name": "stdout", | |
"text": [ | |
"CPU times: user 1min 31s, sys: 1.74 s, total: 1min 33s\n", | |
"Wall time: 23min 43s\n" | |
] | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"top_accounts = pd.DataFrame (list(set(addr)), columns = ['Addr'])\n", | |
"top_accounts = top_accounts.drop_duplicates()\n", | |
"top_accounts" | |
], | |
"metadata": { | |
"id": "Fk7GDjZ3cyfS", | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"outputId": "7947d676-fe13-4afa-a002-0bf2105e2fbc" | |
}, | |
"execution_count": null, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"name": "stdout", | |
"text": [ | |
"94827\n" | |
] | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"from google.colab import files\n", | |
"\n", | |
"top_accounts.to_csv('top_accounts.csv', encoding = 'utf-8-sig') \n", | |
"files.download('top_accounts.csv')" | |
], | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 17 | |
}, | |
"id": "zPtFs5Yw-r8O", | |
"outputId": "0d9e38cb-32ba-49d1-ca22-ca2a3a0c369f" | |
}, | |
"execution_count": null, | |
"outputs": [ | |
{ | |
"output_type": "display_data", | |
"data": { | |
"text/plain": [ | |
"<IPython.core.display.Javascript object>" | |
], | |
"application/javascript": [ | |
"\n", | |
" async function download(id, filename, size) {\n", | |
" if (!google.colab.kernel.accessAllowed) {\n", | |
" return;\n", | |
" }\n", | |
" const div = document.createElement('div');\n", | |
" const label = document.createElement('label');\n", | |
" label.textContent = `Downloading \"${filename}\": `;\n", | |
" div.appendChild(label);\n", | |
" const progress = document.createElement('progress');\n", | |
" progress.max = size;\n", | |
" div.appendChild(progress);\n", | |
" document.body.appendChild(div);\n", | |
"\n", | |
" const buffers = [];\n", | |
" let downloaded = 0;\n", | |
"\n", | |
" const channel = await google.colab.kernel.comms.open(id);\n", | |
" // Send a message to notify the kernel that we're ready.\n", | |
" channel.send({})\n", | |
"\n", | |
" for await (const message of channel.messages) {\n", | |
" // Send a message to notify the kernel that we're ready.\n", | |
" channel.send({})\n", | |
" if (message.buffers) {\n", | |
" for (const buffer of message.buffers) {\n", | |
" buffers.push(buffer);\n", | |
" downloaded += buffer.byteLength;\n", | |
" progress.value = downloaded;\n", | |
" }\n", | |
" }\n", | |
" }\n", | |
" const blob = new Blob(buffers, {type: 'application/binary'});\n", | |
" const a = document.createElement('a');\n", | |
" a.href = window.URL.createObjectURL(blob);\n", | |
" a.download = filename;\n", | |
" div.appendChild(a);\n", | |
" a.click();\n", | |
" div.remove();\n", | |
" }\n", | |
" " | |
] | |
}, | |
"metadata": {} | |
}, | |
{ | |
"output_type": "display_data", | |
"data": { | |
"text/plain": [ | |
"<IPython.core.display.Javascript object>" | |
], | |
"application/javascript": [ | |
"download(\"download_a32c8d21-b28b-4170-aecc-46555936f273\", \"top_accounts.csv\", 4635422)" | |
] | |
}, | |
"metadata": {} | |
} | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment