How to pull json data from multiple http requests

I am trying to write code to pull jason data from multiple stores (The format is where just the final digit in the url changes). For example:

I want to pull the jason data for each store and print to file. What is the best way to go about this?

Here is what I have so far:

import requests
import json
from collections import defaultdict
from tqdm import tqdm

results = defaultdict(list)

url = "{}"
query = "{}"

for store in tqdm(range(1, 5)):
   r =, data={'searchQuery': query.format(store)})
       data = json.loads(r.json()['searchResults'])['results']['online']
       results[store].append((data['price'], data['inventory']))
   except (IndexError, KeyError):

for store, data in results.items():
   print('Store: {}'.format(store))
   if data:
       for inventory, price in data:
          print('\t{} - {}'.format(price, inventory))