Advertisement
Guest User

Untitled

a guest
Jun 24th, 2023
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. import requests
  2.  
  3. def get_sports():
  4. # Make API request to retrieve sports data
  5. api_url = "https://www.thesportsdb.com/api/v1/json/########/all_sports.php"
  6. response = requests.get(api_url)
  7. data = response.json()
  8.  
  9. image_urls = []
  10.  
  11. # Process the retrieved data and collect the image URLs
  12. for sport in data['sports']:
  13. if 'strSportThumb' in sport:
  14. image_urls.append(sport['strSportThumb'])
  15.  
  16. return image_urls
  17.  
  18. # Get the list of image URLs
  19. image_urls = get_sports()
  20.  
  21. # Print the image URLs for testing
  22. for url in image_urls:
  23. print(f"Image: {url}")
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement