Retrieving items in a loop

Viewed 26

I'm trying to retrieve JSON data from https://www.fruityvice.com/api/fruit/.
So, I'm creating a function to do that, but as return i've got only 1 fruit.

import requests
import json

def scrape_all_fruits():
    for ID in range(1, 10):
        url = f'https://www.fruityvice.com/api/fruit/{ID}'
        response = requests.get(url)
        data = response.json()
        return data

print(scrape_all_fruits())

Can anyone explain to me, why ?

0 Answers
Related