InNoobWeTrust
commited on
Commit
•
8dcb148
1
Parent(s):
4b6a96c
fix: bypass cloudflare with session cookie
Browse files
df.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import pandas as pd
|
2 |
import pytz
|
|
|
3 |
import yfinance as yf
|
4 |
|
5 |
from typing import List
|
@@ -42,11 +43,28 @@ def extract_date_index(df):
|
|
42 |
|
43 |
return df
|
44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
def fetch_btc_etf():
|
|
|
|
|
|
|
|
|
47 |
# Get Bitcoin spot ETF history
|
48 |
btc_etf_flow = pd.read_html(
|
49 |
-
|
50 |
attrs={"class": "etf"},
|
51 |
skiprows=[1],
|
52 |
)[0]
|
@@ -65,9 +83,13 @@ def fetch_btc_etf():
|
|
65 |
|
66 |
|
67 |
def fetch_eth_etf():
|
|
|
|
|
|
|
|
|
68 |
# Get Ethereum spot ETF history
|
69 |
eth_etf_flow = pd.read_html(
|
70 |
-
|
71 |
attrs={"class": "etf"},
|
72 |
skiprows=[2, 3],
|
73 |
)[0]
|
|
|
1 |
import pandas as pd
|
2 |
import pytz
|
3 |
+
import requests
|
4 |
import yfinance as yf
|
5 |
|
6 |
from typing import List
|
|
|
43 |
|
44 |
return df
|
45 |
|
46 |
+
FETCH_HEADER = {
|
47 |
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:98.0) Gecko/20100101 Firefox/98.0",
|
48 |
+
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
|
49 |
+
"Accept-Language": "en-US,en;q=0.5",
|
50 |
+
"Accept-Encoding": "gzip, deflate",
|
51 |
+
"Connection": "keep-alive",
|
52 |
+
"Upgrade-Insecure-Requests": "1",
|
53 |
+
"Sec-Fetch-Dest": "document",
|
54 |
+
"Sec-Fetch-Mode": "navigate",
|
55 |
+
"Sec-Fetch-Site": "none",
|
56 |
+
"Sec-Fetch-User": "?1",
|
57 |
+
"Cache-Control": "max-age=0",
|
58 |
+
}
|
59 |
|
60 |
def fetch_btc_etf():
|
61 |
+
r = requests.Session().get(
|
62 |
+
"https://farside.co.uk/bitcoin-etf-flow-all-data/",
|
63 |
+
headers=FETCH_HEADER,
|
64 |
+
)
|
65 |
# Get Bitcoin spot ETF history
|
66 |
btc_etf_flow = pd.read_html(
|
67 |
+
r.content,
|
68 |
attrs={"class": "etf"},
|
69 |
skiprows=[1],
|
70 |
)[0]
|
|
|
83 |
|
84 |
|
85 |
def fetch_eth_etf():
|
86 |
+
r = requests.Session().get(
|
87 |
+
"https://farside.co.uk/ethereum-etf-flow-all-data/",
|
88 |
+
headers=FETCH_HEADER,
|
89 |
+
)
|
90 |
# Get Ethereum spot ETF history
|
91 |
eth_etf_flow = pd.read_html(
|
92 |
+
r.content,
|
93 |
attrs={"class": "etf"},
|
94 |
skiprows=[2, 3],
|
95 |
)[0]
|