InNoobWeTrust commited on
Commit
b7f33b4
1 Parent(s): fe7e87b

fix: bypass cloudflare

Browse files
Files changed (2) hide show
  1. df.py +7 -11
  2. requirements.txt +2 -1
df.py CHANGED
@@ -1,10 +1,8 @@
1
  import pandas as pd
2
  import pytz
3
- import requests
4
  import yfinance as yf
5
 
6
- from datetime import datetime
7
-
8
  from typing import List
9
  from types import SimpleNamespace
10
 
@@ -59,12 +57,13 @@ FETCH_HEADER = {
59
  "Cache-Control": "max-age=0",
60
  }
61
 
 
 
 
 
62
  def fetch_btc_etf():
63
  url = "https://farside.co.uk/bitcoin-etf-flow-all-data/"
64
- r = requests.Session().get(
65
- url,
66
- headers=FETCH_HEADER,
67
- )
68
  print(r.status_code)
69
  if r.status_code != 200:
70
  print(r.content)
@@ -99,10 +98,7 @@ def fetch_btc_etf():
99
 
100
  def fetch_eth_etf():
101
  url = "https://farside.co.uk/ethereum-etf-flow-all-data/"
102
- r = requests.Session().get(
103
- url,
104
- headers=FETCH_HEADER,
105
- )
106
  print(r.status_code)
107
  if r.status_code != 200:
108
  print(r.content)
 
1
  import pandas as pd
2
  import pytz
3
+ import cloudscraper
4
  import yfinance as yf
5
 
 
 
6
  from typing import List
7
  from types import SimpleNamespace
8
 
 
57
  "Cache-Control": "max-age=0",
58
  }
59
 
60
+ def scrape(url: str):
61
+ scraper = cloudscraper.create_scraper()
62
+ return scraper.get(url)
63
+
64
  def fetch_btc_etf():
65
  url = "https://farside.co.uk/bitcoin-etf-flow-all-data/"
66
+ r = scrape(url)
 
 
 
67
  print(r.status_code)
68
  if r.status_code != 200:
69
  print(r.content)
 
98
 
99
  def fetch_eth_etf():
100
  url = "https://farside.co.uk/ethereum-etf-flow-all-data/"
101
+ r = scrape(url)
 
 
 
102
  print(r.status_code)
103
  if r.status_code != 200:
104
  print(r.content)
requirements.txt CHANGED
@@ -4,4 +4,5 @@ yfinance[nospam,repair]==0.2.47
4
  altair
5
  vega
6
  workalendar
7
- pygwalker
 
 
4
  altair
5
  vega
6
  workalendar
7
+ pygwalker
8
+ cloudscraper