-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathget_fees.py
42 lines (30 loc) · 1007 Bytes
/
get_fees.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
# =============================================================================
# File: get_fees.py
# Author: Andre Brener
# Created: 12 Jun 2017
# Last Modified: 12 Jun 2017
# Description: description
# =============================================================================
import requests
import pandas as pd
from bs4 import BeautifulSoup
def get_fee_number(fee_string):
fee_list = [s for s in fee_string.split()]
return float(fee_list[-2])
def get_fee_df(url):
r = requests.get(url)
soup = BeautifulSoup(r.content, 'html.parser')
tag_texts = [
tag.text.strip() for tag in soup.find_all("td")
if len(tag.text.strip()) > 0
]
coins = tag_texts[0::2]
fees = tag_texts[1::2]
df = pd.DataFrame()
df['coin'] = coins
df['coin_fee'] = fees
df['coin_fee'] = df['coin_fee'].apply(get_fee_number)
return df
if __name__ == '__main__':
url = 'http://info.shapeshift.io/about'
print(get_fee_df(url))