-
Notifications
You must be signed in to change notification settings - Fork 0
/
similarweb.py
246 lines (222 loc) · 6.29 KB
/
similarweb.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
#! Python3
"""
File name: treasuries.py
Author: Jonathan Snow
Date created: 10/21/2022
Python Version: 3.9.x
File Details:
Purpose: A series of functions to pull traffic data from
similarweb for a list of URLs.
- Need to create a free trial account on similarweb
- CSS Class could change
"""
# Imports
from modules import data
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.by import By
URL = "https://pro.similarweb.com/#/digitalsuite/websiteanalysis/overview/website-performance/*/999/1m?webSource=Total&key={}"
# WEBDRIVER SETUP
OPTIONS = webdriver.ChromeOptions()
OPTIONS.add_argument("--start-maximized")
OPTIONS.add_argument("--disable-infobars")
OPTIONS.add_argument("--window-size=2000,3000")
driver = webdriver.Chrome(options=OPTIONS)
STATS_CLASS = "MetricValue-edQheR"
APP_CLASS = "a.AppIconLink-OjIKx"
##################################################
def main():
"""
Function to gather treasury addresses from Cryptostats.
"""
output = []
# List of all websites to process
websites = [
'rabby.io',
'tally.cash',
'bitkeep.com',
'www.ledger.com',
'etherscan.io',
'ethereum.org',
'www.sushi.com',
'balancer.fi',
'lunarcrush.com',
'walleth.org',
'mooniswap.exchange',
'www.defipulse.com',
'www.dapp.com',
'dappradar.com',
'www.tokensets.com',
'vemarketcap.com',
'sablier.finance',
'kyberswap.com',
'www.exodus.com',
'www.numio.one',
'www.safepal.com',
'www.ellipal.com',
'www.coinomi.com',
'www.pillar.fi',
'www.nansen.ai',
'defisaver.com',
'paxos.com',
'tangany.com',
'www.vauld.com',
'tokenlists.org',
'xangle.io',
'hextrust.com',
'home.bancor.network',
'www.venly.io',
'liquidswap.com',
'frame.sh',
'transak.com',
'www.frontier.xyz',
'www.matcha.xyz',
'fortmatic.com',
'wallet.polygon.technology',
'www.etherwall.com',
'www.parity.io',
'alphawallet.com',
'freewallet.org',
'www.balance.io',
'www.amberdata.io',
'ann.hoo.comannouncement',
'myabcwallet.io',
'airgap.io',
'bitpie.com',
'blockmove.io',
'www.buntoy.com',
'cobo.com',
'www.cryptonator.com',
'cryptopay.me',
'www.dexwallet.io',
'btxpro.com',
'etherscan.io',
'www.hel.io',
'hut34.io',
'www.infinitowallet.io',
'particl.io',
'phenom-elon.com',
'ww25.qbao.fund',
'mysafewallet.io',
'diversifi.app',
'monarchwallet.com',
'midasprotocol.io',
'monolith.xyz',
'gocrypto.com',
'block.cc',
'www.atoken.com',
'unocoin.com',
'klever.io',
'www.birdchainapp.com',
'blockstream.com',
'totalcoin.io',
'tenx.tech',
'www.hb-wallet.com',
'www.socios.com',
'natrium.io',
'quppy.com',
'litecoin.org',
'coindirect.com',
'www.coinspot.com.au',
'cash.app',
'bitcoin.com',
'lobstr.co',
'www.coinpayments.net',
'www.maicoin.com',
'www.wombat.app',
'www.tronlink.org',
'electrum.org',
'choise.com',
'spectrocoin.com',
'swipe.io',
'www.jstcap.com',
'www.xdefi.io',
'www.airswap.io',
'www.altonomy.com',
'dydx.exchange',
'peakdefi.com',
'staker.app',
'o3.network',
'unstoppable.money',
'synthetix.io',
'wazirx.com',
'www.cypherwallet.io',
'www.coinzoom.com',
'linen.app',
'multis.com',
'walleth.org',
'www.sktelecom.com',
'keys.casa',
'www.ethvm.com',
'mewconnect.myetherwallet.com',
'elasticswap.org',
'teleport.network',
'www.enkrypt.com',
'www.minke.app',
'hyve.works',
'arcticwallet.io',
'omni.app',
'www.hyperpay.tech',
'defiantapp.tech',
'www.zulutransfer.com',
'exponential.fi',
'walletnow.app',
'changehero.io',
'exolix.com',
'letsexchange.io',
'godex.io',
'sideshift.ai',
'www.switchain.com',
'thegivingblock.com',
'cryptowallet.com',
'burritowallet.com'
]
# Login to website
login()
# Loop through websites in list
for url in websites:
result = process(url)
output.append(result)
# Dump balance data to CSV
output_path = "files/output"
output_name = "sw_sites-1.csv"
data.save(output, output_path, output_name, ["url", "traffic", "users", "ios_id", "android_id"])
##############################################################
def login():
"""
Function to log in to similarweb.com
"""
driver.get(URL)
sleep(45) # Allow 30s to log into application
##############################################################
def process(website):
"""
Function to process a website on similarweb.com
"""
app_ios = []
app_android = []
driver.get(URL.format(website))
sleep(5)
elements = driver.find_elements(By.CLASS_NAME, STATS_CLASS)
# Grab relevant traffic and user data from page
traffic = elements[0].text
users = elements[1].text
print(website, ", ", traffic, ", ", users)
# Grab relevant app data links
app_elements = driver.find_elements(By.CSS_SELECTOR, APP_CLASS)
# Loop over apps listed and extract app ID codes
if len(app_elements) > 0:
for app in app_elements:
link = app.get_attribute('href').replace("https://pro.similarweb.com/#/apps/performance/", "").split("/")[0]
print(link)
# Sort link by App Store
if "1_" in link:
app_ios.append(link.replace("1_",""))
elif "0_" in link:
app_android.append(link.replace("0_",""))
sleep(10)
return [website, traffic, users, app_ios, app_android]
##################################################
# Runtime Entry Point
if __name__ == "__main__":
main()