Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3667

Issue with Tastedive API in Data Collection and Processing with Python Course (University of Michigan Runstone Environment)

$
0
0

I'm currently working on an assignment for the "Data Collection and Processing with Python" course at the University of Michigan, using the Runstone code environment. The assignment involves interacting with the TasteDive API. However, the API seems to be returning HTML responses instead of JSON, making it challenging to proceed.

Here's a snippet of the assignment note:

Note: the tasteDive API is no longer functional, however, it still works within the Runestone environment through the "requests_with_caching.get()" function.

Could someone provide guidance on how to troubleshoot or adapt my code to handle this situation within the constraints of the Runstone environment?

import requests_with_cachingimport json def get_movies_from_tastedive(movie_name):    baseurl = "https://tastedive.com/api/similar"    params = {'q': movie_name,'type': 'movies','limit': 5,    }    tastedive_resp = requests_with_caching.get(baseurl, params=params, permanent_cache_file="tastedive_cache.txt")    try:        tastedive_data = tastedive_resp.json()        print(json.dumps(tastedive_data, indent=2))  # Print the entire response for analysis        return tastedive_data['Similar']['Results']    except KeyError:        print(f"Error: Unable to fetch data from TasteDive {KeyError}")        print(tastedive_resp.text)        return Noneget_movies_from_tastedive("Bridesmaids")get_movies_from_tastedive("Black Panther")

I get an HTML when I run:

new; adding to cache
{"error":"Response not interpretable as json. Try printing the .text attribute"}
Error: Unable to fetch data from TasteDive <class 'KeyError'>
<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="viewport" content="width=device-width, initial-scale=1.0, >/_next/static/chunks/2471.1a8e41d22ea50520.js"></script><script defer="" src="/_next/static/chunks/3080.af7b35044303ba73.js"></script><script defer="" src="/_next/static/chunks/2478.2589579ffc122b2b.js"></script><script src="/_next/static/chunks/webpack-f73e882e0d7fc3ea.js" defer=""></script><script src="/_next/static/..

Despite following the instructions and using the provided requests_with_caching.get() function, I'm consistently receiving HTML responses. I have also tried using the standard requests.get() function without success.

TasteDive API documentation


Viewing all articles
Browse latest Browse all 3667

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>