diff --git a/scrape-all.sh b/scrape-all.sh index 324303b..e2f94e4 100755 --- a/scrape-all.sh +++ b/scrape-all.sh @@ -15,20 +15,22 @@ update_cache() { } get_number_of_search_pages() { - local results=$(curl "https://www.bbcgoodfood.com/api/search-frontend/search?limit=1&${search_args}" -s | jq '.searchResults.totalItems') + local results + results=$(curl "https://www.bbcgoodfood.com/api/search-frontend/search?limit=1&${search_args}" -s | jq '.searchResults.totalItems') - if [[ $(($results % recipies_per_search)) == 0 ]]; then - echo $(($results / $recipies_per_search)) + if [[ $((results % recipies_per_search)) == 0 ]]; then + echo $((results / recipies_per_search)) else - echo $(($results / $recipies_per_search + 1)) + echo $((results / recipies_per_search + 1)) fi } get_main_ingredients() { + local data if [[ -z "$1" ]]; then - local data=$cache + data=$cache else - local data=$(curl $1 -s) + data=$(curl "$1" -s) fi echo "$data" | htmlq -p | grep '.*' | sed 's/^.*//' | sed 's/<\/a>.*//' | sed 's/,//' @@ -36,10 +38,11 @@ get_main_ingredients() { } get_page_json() { # Unused - but could be helpful for expanding this out layer + local data if [[ -z "$1" ]]; then - local data=$cache + data=$cache else - local data=$(curl $1 -s) + data=$(curl "$1" -s) fi echo "$data" | htmlq -p | grep '