-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathetherscan webscraper2.0.py
More file actions
51 lines (34 loc) · 1.39 KB
/
etherscan webscraper2.0.py
File metadata and controls
51 lines (34 loc) · 1.39 KB
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
#! Etherscan Transaction and Balaance scraper
import json
import requests
address=input("Enter addess: ")
#returns 10 last records from the oldest to the newest
#However, this can give 10,000 records max
url_1="http://api.etherscan.io/api?module=account&action=txlist&address="+ address + \
"&startblock=0&endblock=99999999&page=10&offset=10&sort=desc&apikey=YourApiKeyToken"
response= requests.get(url_1)
address_content=response.json()
result_1= address_content.get("result")
for n, transaction in enumerate(result_1, start=1):
hash= transaction.get("hash")
time_stamp=transaction.get("timeStamp")
tx_from=transaction.get("from")
tx_to=transaction.get("to")
value=transaction.get("value")
confirmations=transaction.get("confirmations")
print("Transaction ID: ", n)
print("hash: ", hash)
print("Time Stamp", time_stamp)
print("from: ", tx_from)
print("to: ", tx_to)
print ("value: ", value)
print ("confirmations: ", confirmations)
print ("\n")
#Scraping Balance ether
url_2=("https://api.etherscan.io/api?module=account&action=balance&address="+ address +"&tag=latest&apikey=YourApiKeyToken")
results=requests.get(url_2)
#results=requests.get(url)
addr_content=results.text
dic_addr_content=json.loads(addr_content)
print ("BALANCE: \n" + dic_addr_content["result"] +" "+ "ether")
#END