The snippet containing descriptive details of each videoħ To finish up, we assigned the title and description properties that are nested within the snippet object to local variables.ĨAll finished! Run the code to try it out. The array of videos in the search results To do this, you'll use the following square bracket syntax for specifying the items array, then the first item in that array (at index 0), and finally the snippet object within the first item in the array: The two main elements you should look for are:įor these results, we wanted the title and description of the first video in the search results. It helps to look at the JSON file's structure to get an idea of how it is organized. Title = dataĭescription = dataĥFirst we converted the JSON text from the response to a list.Ħ Next, we parsed out the piece of data we want from the JSON. # Parse title and description properties. ListSearchResultsResults = listSearchResultsChoreo.execute_with_results(listSearchResultsInputs)ĭata = json.loads(listSearchResultsResults.get_Response()) ListSearchResultsInputs = listSearchResultsChoreo.new_input_set() ListSearchResultsChoreo = ListSearchResults(session) # Instantiate the choreo, using the session object Session = TembooSession('ACCOUNT_NAME', 'APP_NAME', 'APP_KEY') In steps 5-8, we'll go over what happens in the code.įrom import TembooSessionįrom import ListSearchResults Next we'll see how to parse through this response in Python and pick out only the pieces we're interested in. Select Python from the drop down menu at the top of the page.Ģ Enter any search term you want for the Query input and click Generate Code to test the Choreo from our website.ģ You get a whole bunch of JSON in the Response output. Get JSON outputġ Log in to Temboo and go to the YouTube > Search > ListSearchResults Choreo in our Library. Although we use the output from our YouTube ListSearchResults Choreo in this tutorial, the same steps we outline here will work for parsing any JSON in Python. This tutorial assumes that you've already gone through our Python getting started tutorial and are familiar with how our Python SDK works. Here we'll review JSON parsing in Python so that you can get to the interesting data faster. A lot of APIs will give you responses in JSON format.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |