Skip to content

Commit 7d0f0a1

Browse files
committed
[QOL] [retrieveAll] ignorelist gnosis+eth2 label
1 parent e0e2bc7 commit 7d0f0a1

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

main.py

+19-12
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
import time
55
import os.path
66

7-
driver = webdriver.Chrome()
8-
with open('config.json', 'r') as f:
9-
config = json.load(f)
10-
117
# Login to etherscan and auto fill login information if available
128
def login():
139
driver.get('https://etherscan.io/login')
@@ -19,8 +15,9 @@ def login():
1915

2016
input("Press enter once logged in")
2117

18+
2219
# Retrieve label information and saves as JSON/CSV
23-
def getLabel(label,type='single'):
20+
def getLabel(label, type='single'):
2421
baseUrl = 'https://etherscan.io/accounts/label/{}?subcatid=0&size=100&start={}'
2522
index = 0 # Initialize start index at 0
2623
table_list = []
@@ -31,7 +28,7 @@ def getLabel(label,type='single'):
3128
try:
3229
newTable = pd.read_html(driver.page_source)[0]
3330
except ImportError:
34-
print(label,"Skipping label due to error")
31+
print(label, "Skipping label due to error")
3532
return
3633
table_list.append(newTable[:-1]) # Remove last item which is just sum
3734
index += 100
@@ -42,7 +39,7 @@ def getLabel(label,type='single'):
4239
df.fillna('', inplace=True) # Replace NaN as empty string
4340

4441
# Prints length and save as a csv
45-
print(label,'Df length:', len(df.index))
42+
print(label, 'Df length:', len(df.index))
4643
df.to_csv('data/{}.csv'.format(label))
4744

4845
# Save as json object with mapping address:nameTag
@@ -51,14 +48,15 @@ def getLabel(label,type='single'):
5148
with open('data/{}.json'.format(label), 'w', encoding='utf-8') as f:
5249
json.dump(addressNameDict, f, ensure_ascii=True)
5350

54-
if (type=='single'):
51+
if (type == 'single'):
5552
endOrContinue = input(
5653
'Type "exit" end to end or "label" of interest to continue')
5754
if (endOrContinue == 'exit'):
5855
driver.close()
5956
else:
6057
getLabel(endOrContinue)
6158

59+
6260
# Retrieves all labels from labelcloud and saves as JSON/CSV
6361
def getAllLabels():
6462
driver.get('https://etherscan.io/labelcloud')
@@ -77,14 +75,23 @@ def getAllLabels():
7775

7876
for label in labels:
7977
if (os.path.exists('data/{}.csv'.format(label))):
80-
print(label,'already exists skipping.')
78+
print(label, 'already exists skipping.')
8179
continue
82-
getLabel(label,'all')
83-
time.sleep(5) # Give 5s interval to prevent RL
80+
elif label in ignore_list:
81+
print(label,'ignored due to large size and irrelevance')
82+
continue
83+
getLabel(label, 'all')
84+
time.sleep(5) # Give 5s interval to prevent RL
85+
86+
87+
ignore_list = ['eth2-depositor', 'gnosis-safe-multisig']
88+
with open('config.json', 'r') as f:
89+
config = json.load(f)
90+
driver = webdriver.Chrome()
8491

8592
login()
8693
retrievalType = input('Enter retrieval type (single/all): ')
87-
if (retrievalType=='all'):
94+
if (retrievalType == 'all'):
8895
getAllLabels()
8996
else:
9097
singleLabel = input('Enter label of interest: ')

0 commit comments

Comments
 (0)