mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-04-05 18:09:04 +00:00
28 lines
705 B
Bash
Executable File
28 lines
705 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Fetch breweries data from OpenBreweryDB API and save to JSON files.
|
|
# Saves results to misc/raw-data/breweries-complete.json
|
|
|
|
OUTPUT_DIR="misc/raw-data"
|
|
API_BASE="https://api.openbrewerydb.org/v1/breweries"
|
|
|
|
mkdir -p "$OUTPUT_DIR"
|
|
|
|
echo "Fetching breweries from OpenBreweryDB API..."
|
|
echo "[]" > "$OUTPUT_FILE"
|
|
|
|
total_count=0
|
|
|
|
for page in {1..30}; do
|
|
echo "Fetching page $page..."
|
|
|
|
curl -s "$API_BASE?per_page=200&page=$page" | \
|
|
jq '.' > "$OUTPUT_DIR/page-$page.json"
|
|
|
|
count=$(jq 'length' "$OUTPUT_DIR/page-$page.json")
|
|
total_count=$((total_count + count))
|
|
echo " Got $count breweries (total: $total_count)"
|
|
done
|
|
|
|
echo "Done fetching. Total breweries fetched: $total_count"
|