Add function to request csv from CubeCobra
Add function to request csv from CubeCobra
This commit is contained in:
parent
a292ffb34e
commit
3e409aad0f
1 changed files with 8 additions and 0 deletions
|
|
@ -1,9 +1,17 @@
|
||||||
import csv
|
import csv
|
||||||
import json
|
import json
|
||||||
|
import requests
|
||||||
|
|
||||||
from word_count import EXPECTED_HEADER, COLUMNS, TEMP_JSON, is_actual_mtg_card
|
from word_count import EXPECTED_HEADER, COLUMNS, TEMP_JSON, is_actual_mtg_card
|
||||||
|
|
||||||
|
|
||||||
|
def request_cube_csv(cube_name, cube_id):
|
||||||
|
url = f'https://cubecobra.com/cube/download/csv/{cube_id}'
|
||||||
|
url += '?primary=Color%20Category&secondary=Types-Multicolor&tertiary=CMC2'
|
||||||
|
response = requests.get(url)
|
||||||
|
open(f'cube_csvs/{cube_name}.csv', 'wb').write(response.content)
|
||||||
|
|
||||||
|
|
||||||
def load_cube_from_csv(filename, tag_filter=None):
|
def load_cube_from_csv(filename, tag_filter=None):
|
||||||
cards = []
|
cards = []
|
||||||
with open(filename) as f:
|
with open(filename) as f:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue