Skip to content

Instantly share code, notes, and snippets.

@michelem09
Last active June 3, 2020 05:46
Show Gist options
  • Save michelem09/d8fabfd617b00b0c9ed3b6bc4acce560 to your computer and use it in GitHub Desktop.
Save michelem09/d8fabfd617b00b0c9ed3b6bc4acce560 to your computer and use it in GitHub Desktop.
Simple bash script to get list of latest 50 active nodes for Ethereum blockchain (ETH mainnet) from https://www.ethernodes.org/network/1/nodes. Useful to have the list ready for Parity bootnodes config option.
#!/bin/bash
### Usage ###
# ./get_eth_nodes.sh <json | strings>
# Use json to get an array of nodes in JSON suitable for Parity
# Use strings to get a list of nodes line by line
#############
ARRAY=()
NODES=`curl -s 'https://www.ethernodes.org/network/1/data?draw=1&columns%5B0%5D%5Bdata%5D=id&columns%5B0%5D%5Bname%5D=&columns%5B0%5D%5Bsearchable%5D=true&columns%5B0%5D%5Borderable%5D=true&columns%5B0%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B0%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B1%5D%5Bdata%5D=host&columns%5B1%5D%5Bname%5D=&columns%5B1%5D%5Bsearchable%5D=true&columns%5B1%5D%5Borderable%5D=true&columns%5B1%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B1%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B2%5D%5Bdata%5D=port&columns%5B2%5D%5Bname%5D=&columns%5B2%5D%5Bsearchable%5D=true&columns%5B2%5D%5Borderable%5D=true&columns%5B2%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B2%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B3%5D%5Bdata%5D=country&columns%5B3%5D%5Bname%5D=&columns%5B3%5D%5Bsearchable%5D=true&columns%5B3%5D%5Borderable%5D=true&columns%5B3%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B3%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B4%5D%5Bdata%5D=clientId&columns%5B4%5D%5Bname%5D=&columns%5B4%5D%5Bsearchable%5D=true&columns%5B4%5D%5Borderable%5D=true&columns%5B4%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B4%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B5%5D%5Bdata%5D=client&columns%5B5%5D%5Bname%5D=&columns%5B5%5D%5Bsearchable%5D=true&columns%5B5%5D%5Borderable%5D=true&columns%5B5%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B5%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B6%5D%5Bdata%5D=clientVersion&columns%5B6%5D%5Bname%5D=&columns%5B6%5D%5Bsearchable%5D=true&columns%5B6%5D%5Borderable%5D=true&columns%5B6%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B6%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B7%5D%5Bdata%5D=os&columns%5B7%5D%5Bname%5D=&columns%5B7%5D%5Bsearchable%5D=true&columns%5B7%5D%5Borderable%5D=true&columns%5B7%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B7%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B8%5D%5Bdata%5D=lastUpdate&columns%5B8%5D%5Bname%5D=&columns%5B8%5D%5Bsearchable%5D=true&columns%5B8%5D%5Borderable%5D=true&columns%5B8%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B8%5D%5Bsearch%5D%5Bregex%5D=false&order%5B0%5D%5Bcolumn%5D=0&order%5B0%5D%5Bdir%5D=asc&start=0&length=25&search%5Bvalue%5D=&search%5Bregex%5D=false&_=1528093816442'`
for row in $(echo "${NODES}" | jq -r '.data[] | @base64'); do
_jq() {
echo ${row} | base64 --decode | jq -r ${1}
}
ARRAY+=("enode://"$(_jq '.id')"@"$(_jq '.host')":"$(_jq '.port'))
done
if [ "$1" == "json" ]
then
printf '%s\n' "${ARRAY[@]}" | jq -R . | jq -s -c .
else
printf '%s\n' "${ARRAY[@]}"
fi
@michelem09
Copy link
Author

Sample json output:

["enode://0000e398b29de2a69a508b3f0f4d26299b5e43f9e188f0fc603c699836695b0009866d047bd42aae1bfe74398ebefde834217b57b84e7043ed26b72f515e453f@178.200.236.227:24603","enode://0002bcd1516aa9fa361669b87cdda510d69f9e5fc399ab628ae0623c64fd9d6b0d08f44522270ddd4bc437f0e3e3bb94e5aefe6d4e5806e4feb8c9dc94512c40@188.72.98.122:30303","enode://0004e7705071f5932377a9ab491b3132fc07cd6bee87bb22e0c57c8502dd68a80b09339dd5befe82bd29e4ab26080e3e1292b0110375c5d1d48612c4f247edae@158.196.244.180:40746","enode://0011e1e827c32681049d00bf2a7a4502065b097cebe102fc24084ef1476cc7d0f0fc5b329bbcd7f180dbb3bd027a6c5285a194ee1bd9d8cbbef2445eae4a77b9@178.196.186.156:33208","enode://0013488225fa03b13c2da53fd3d3c3fe7e365a09ee74caa743fb318a4a90b7ecf5b714710804c3d070056a403451b664a64ccc5fc4174e9cc30097a60662ff71@128.237.152.82:34584","enode://0019c2b0b1a1564b4e52d3b3d58f5e707328d0fb3f58990d6860ab37ac5c5100ed4f1ab26b433ab8dc9d8629b3a369f38bf64fb2885af3819c45e5b15989c1ef@34.201.103.213:30303","enode://001b53803dea44b6bbfc4a7f70f0ec05d5dca9af857cb1b02cac6c5c026f4a4068248842fff30843d491745e86c6483f9e5903597ba7260a87407c28797bff4f@185.65.53.127:30303","enode://0023b7c8e097a86ef97d5e8960edd9cfac4f4e926f413273785579f868b9f83b5990d47e075e1bd289e8abfabc58766a8698b585572da96584acf7b44585df64@119.23.136.252:30303","enode://002517c0ec70bb75c4a50100669c06781af42c21062c46a7300d0acf595ef5e71456409810345acac16807d3d5c9f0c4883ea3b68093bc45b189288e654c07ac@ec2-35-154-153-81.ap-south-1.compute.amazonaws.com:30303","enode://0029568bf249fcff009ff6adb646bf16a958e4c329b6dfce8cd881f144ce4b493f884adf175d5a9084bcda951d67b30521e1fa11846bac49964d100e01d48ab6@slave.pool.sexy:10974","enode://002bb5601892b670f165b84a840958249bcf01c06b007eba18efb50db847767ed6823f2e77d1ff2c86ce7493961edd760022b0d45d44b5c4fb62a5bc6d96ccfd@45.76.194.71:59348","enode://002c109def19f9a24782dabc634e0607347bdf5b5b4866990c2e9b3648547109000d64bfd684843049b0fdc457e3da3f75cad80cdd67c86c0c73205fadfe2523@119.137.55.63:9827","enode://002d8858fedcf3f8b6f2d0f1694e9da4146f7dba8a967bdce8e5ee0256d36d7110aa3adafc136f17c50495a21e355076626267195128897aaf13a97be3d7ac88@87.236.196.138:9474","enode://0037e3182738b2c4f8e6c27c37a5b96bc4c3531961e40b7f02df7e1bd1030b83803c5bf2ecc75d20bb00dbc8d6ce54d56e96ecc8d7f623f2db295dec6bf6a914@42-98-118-055.static.netvigator.com:30303","enode://003eedc4ffae3a14edbcbc9d53ed7e28a4fea6f6c606878c58c6ab33dc986e275b0d637099d0227c009d571cbff7d78e45c2e1a7a8df9c05dc6dd4a854474fe4@190.196.217.202:57988","enode://0042fef8ff987767bf31a7be2cc742ff1cb1d55a0adb743cb84278c0cd1b18141bab4ef59bfd51be13106c1ddc8955963ea3fcf3f00a33a1731b8fe26801a13f@13.57.61.129:30303","enode://00444714936099f31c5eb5abfa33e1e9347f0aa819d689f6793c24af34494abee4795cc19a90ddf8749d6cceda4ac0760e9a403a4711dc991a885a965d4ed9ac@149.129.129.190:45622","enode://00499d5be7d9262eb66e1bffd4004e806efbb8e7effb80cff40c7adf6a7935d3e87f85e320023488637cbaa90b8612f625935ce9fc53ad73c567827edcc4b0f2@91.204.224.19:53001","enode://004ceaba45caa665f4b6e95f403082a5cca7c393502c1ce4333ec9efe69770528847f2d29930effcbb643ef6119716e480f510a4088b24b086b4b3d94912a2df@209.182.216.57:30303","enode://00511dc068382544c5d260f50e802fb3d8d9ad0d5143011feb205361dadb7d05cd519b2e04323333adbac65dc7b2e4ca994f20692b1278f3b891f9fea43f05ad@47.42.107.5:59386","enode://00515b7cb52d01092221bf2d5eb4c889e3db6253ce0649247f5aa39a095de9c8429da5b1223c5b92579fc8e0f53ea175678e1b8a6f0a33ea48638139825ecd0d@164.132.121.49:33062","enode://0059376e51506db004e5febcf563477ebe6b64b501ed883c1fbe337dab6b6fdad9a8e8c96c97f0b3aa20f73b3483aa445cc9fe9df17b30192ebbfc6877d73b14@120.236.0.205:56036","enode://0060090eefe47fc3af80d7408199edfa93e68388ea9df4dc5e86b122350a7d9a467cd4b03b794e2146abfdea30d4b33f0580fd2fc4a93d85da34137a4b1a1cf7@159.89.156.144:30303","enode://0060429370f8a1b44b27997fa0b6e0e2e665d3629ae9051ddb94cfd5d8a112f0c4b71c9beea2bb6d6fa3c360fd365ce5657fb0694e7709aad8924d8d9101f1ed@ec2-52-59-208-29.eu-central-1.compute.amazonaws.com:30303","enode://00620e0806dea0219ac4787f6f62df2fb321ae84e93814877ec194d2d692005bf4b7c7ebb33600b35761d21925562c35c996a411043fa47d5e584c3ba689f73f@101.88.238.139:57244"]

Sample strings output:

enode://0000e398b29de2a69a508b3f0f4d26299b5e43f9e188f0fc603c699836695b0009866d047bd42aae1bfe74398ebefde834217b57b84e7043ed26b72f515e453f@178.200.236.227:24603
enode://0002bcd1516aa9fa361669b87cdda510d69f9e5fc399ab628ae0623c64fd9d6b0d08f44522270ddd4bc437f0e3e3bb94e5aefe6d4e5806e4feb8c9dc94512c40@188.72.98.122:30303
enode://0004e7705071f5932377a9ab491b3132fc07cd6bee87bb22e0c57c8502dd68a80b09339dd5befe82bd29e4ab26080e3e1292b0110375c5d1d48612c4f247edae@158.196.244.180:40746
enode://0011e1e827c32681049d00bf2a7a4502065b097cebe102fc24084ef1476cc7d0f0fc5b329bbcd7f180dbb3bd027a6c5285a194ee1bd9d8cbbef2445eae4a77b9@178.196.186.156:33208
enode://0013488225fa03b13c2da53fd3d3c3fe7e365a09ee74caa743fb318a4a90b7ecf5b714710804c3d070056a403451b664a64ccc5fc4174e9cc30097a60662ff71@128.237.152.82:34584
enode://0019c2b0b1a1564b4e52d3b3d58f5e707328d0fb3f58990d6860ab37ac5c5100ed4f1ab26b433ab8dc9d8629b3a369f38bf64fb2885af3819c45e5b15989c1ef@34.201.103.213:30303
enode://001b53803dea44b6bbfc4a7f70f0ec05d5dca9af857cb1b02cac6c5c026f4a4068248842fff30843d491745e86c6483f9e5903597ba7260a87407c28797bff4f@185.65.53.127:30303
enode://0023b7c8e097a86ef97d5e8960edd9cfac4f4e926f413273785579f868b9f83b5990d47e075e1bd289e8abfabc58766a8698b585572da96584acf7b44585df64@119.23.136.252:30303
enode://002517c0ec70bb75c4a50100669c06781af42c21062c46a7300d0acf595ef5e71456409810345acac16807d3d5c9f0c4883ea3b68093bc45b189288e654c07ac@ec2-35-154-153-81.ap-south-1.compute.amazonaws.com:30303
enode://0029568bf249fcff009ff6adb646bf16a958e4c329b6dfce8cd881f144ce4b493f884adf175d5a9084bcda951d67b30521e1fa11846bac49964d100e01d48ab6@slave.pool.sexy:10974
enode://002bb5601892b670f165b84a840958249bcf01c06b007eba18efb50db847767ed6823f2e77d1ff2c86ce7493961edd760022b0d45d44b5c4fb62a5bc6d96ccfd@45.76.194.71:59348
enode://002c109def19f9a24782dabc634e0607347bdf5b5b4866990c2e9b3648547109000d64bfd684843049b0fdc457e3da3f75cad80cdd67c86c0c73205fadfe2523@119.137.55.63:9827
enode://002d8858fedcf3f8b6f2d0f1694e9da4146f7dba8a967bdce8e5ee0256d36d7110aa3adafc136f17c50495a21e355076626267195128897aaf13a97be3d7ac88@87.236.196.138:9474
enode://0037e3182738b2c4f8e6c27c37a5b96bc4c3531961e40b7f02df7e1bd1030b83803c5bf2ecc75d20bb00dbc8d6ce54d56e96ecc8d7f623f2db295dec6bf6a914@42-98-118-055.static.netvigator.com:30303
enode://003eedc4ffae3a14edbcbc9d53ed7e28a4fea6f6c606878c58c6ab33dc986e275b0d637099d0227c009d571cbff7d78e45c2e1a7a8df9c05dc6dd4a854474fe4@190.196.217.202:57988
enode://0042fef8ff987767bf31a7be2cc742ff1cb1d55a0adb743cb84278c0cd1b18141bab4ef59bfd51be13106c1ddc8955963ea3fcf3f00a33a1731b8fe26801a13f@13.57.61.129:30303
enode://00444714936099f31c5eb5abfa33e1e9347f0aa819d689f6793c24af34494abee4795cc19a90ddf8749d6cceda4ac0760e9a403a4711dc991a885a965d4ed9ac@149.129.129.190:45622
enode://00499d5be7d9262eb66e1bffd4004e806efbb8e7effb80cff40c7adf6a7935d3e87f85e320023488637cbaa90b8612f625935ce9fc53ad73c567827edcc4b0f2@91.204.224.19:53001
enode://004ceaba45caa665f4b6e95f403082a5cca7c393502c1ce4333ec9efe69770528847f2d29930effcbb643ef6119716e480f510a4088b24b086b4b3d94912a2df@209.182.216.57:30303
enode://00511dc068382544c5d260f50e802fb3d8d9ad0d5143011feb205361dadb7d05cd519b2e04323333adbac65dc7b2e4ca994f20692b1278f3b891f9fea43f05ad@47.42.107.5:59386
enode://00515b7cb52d01092221bf2d5eb4c889e3db6253ce0649247f5aa39a095de9c8429da5b1223c5b92579fc8e0f53ea175678e1b8a6f0a33ea48638139825ecd0d@164.132.121.49:33062
enode://0059376e51506db004e5febcf563477ebe6b64b501ed883c1fbe337dab6b6fdad9a8e8c96c97f0b3aa20f73b3483aa445cc9fe9df17b30192ebbfc6877d73b14@120.236.0.205:56036
enode://0060090eefe47fc3af80d7408199edfa93e68388ea9df4dc5e86b122350a7d9a467cd4b03b794e2146abfdea30d4b33f0580fd2fc4a93d85da34137a4b1a1cf7@159.89.156.144:30303
enode://0060429370f8a1b44b27997fa0b6e0e2e665d3629ae9051ddb94cfd5d8a112f0c4b71c9beea2bb6d6fa3c360fd365ce5657fb0694e7709aad8924d8d9101f1ed@ec2-52-59-208-29.eu-central-1.compute.amazonaws.com:30303
enode://00620e0806dea0219ac4787f6f62df2fb321ae84e93814877ec194d2d692005bf4b7c7ebb33600b35761d21925562c35c996a411043fa47d5e584c3ba689f73f@101.88.238.139:57244

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