@@ -73,16 +73,45 @@ def getLabel(label, label_type="account", input_type='single'):
7373 # Retrieve all addresses from table
7474 elems = driver .find_elements ("xpath" , "//tbody//a[@href]" )
7575 addressList = []
76+ tokenNameList = []
7677 addrIndex = len (baseUrl + '/address/' )
7778 for elem in elems :
7879 href = elem .get_attribute ("href" )
80+ #print('href:',href)
7981 if (href .startswith (baseUrl + '/address/' )):
8082 addressList .append (href [addrIndex :])
83+ elif href .startswith (baseUrl + '/token/' ):
84+
85+ if '...' in elem .text :
86+ #try:
87+ # Check if the element has the tooltip attribute
88+ tooltip_element = elem .find_element_by_xpath (".//span[@data-bs-toggle='tooltip']" )
89+
90+ # Use execute_script to get tooltip text via JavaScript
91+ tooltip_text = driver .execute_script ("""
92+ var tooltipElement = arguments[0];
93+ var tooltipInstance = bootstrap.Tooltip.getInstance(tooltipElement);
94+ return tooltipInstance ? tooltipInstance._config.originalTitle : null;
95+ """ , tooltip_element )
96+
97+ print ('Tooltip text found:' ,tooltip_text )
98+ tokenNameList .append (tooltip_text )
99+ #except:
100+ else :
101+ # Tooltip doesn't exist, just use the element text
102+ formattedText = elem .text .replace ('\n ' ,' ' )
103+ print ('TokenName:' ,formattedText )
104+
105+ # Replace newline with whitespace
106+ tokenNameList .append (formattedText )
107+
108+
81109
82110 # Quickfix: Optimism uses etherscan subcat style but differing address format
83111 if targetChain == 'eth' :
84112 # Replace address column in newTable dataframe with addressList
85113 curTable ['Address' ] = addressList
114+ curTable ['Token Name' ] = tokenNameList
86115 except Exception as e :
87116 print (e )
88117 print (label , "Skipping label due to error" )
0 commit comments