Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python help using jupyter notebook http://www.filedropper.com/lab9-pythonrequests https://ufile.io/bwfzqv9d jupyter Lab9-PythonRequests Last Checkpoint: 13 minutes ago (autosaved) Logout File Edit View Insert Cell Kernel Widgets Help Not

python help using jupyter notebook

http://www.filedropper.com/lab9-pythonrequests

https://ufile.io/bwfzqv9d

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed
jupyter Lab9-PythonRequests Last Checkpoint: 13 minutes ago (autosaved) Logout File Edit View Insert Cell Kernel Widgets Help Not Trusted | Python 3 + Run C Markdown PART B (90 points) Penguin Random House - Business Services.biz (REST SERVICES APIs) URL: http://www.penguinrandomhouse.biz/webservices/rest/ In [28]: import requests import json Use the GET /resources/authors API -- search for authors (18 points) http://www.penguinrandomhouse.biz/webservices/rest/#authors Search for firstName=Dan & lastName=Brown Use the Penguin Random House API to do a GET request - Include search for author Dan Brown Include headers value of 'Accept': 'application/json' Print the Response text In [39]: M # INSERT GET WITH SEARCH & HEADERS. PRINT RESPONSE TEXT - Use json.loads to convert the text string into a Python dict/list Print the JSON using json.dumps with indent=4, sort_keys= True to make it easier to read (see Labs) In [41]: M # INSERT JSON. LOADS and JSON. DUMPS CODE Get data from the JSON ... -Get the authorid value - Print the authorid value In [43]: ) # INSERT GET & PRINT OF JSON 'authorid' VALUEjupyter Lab9-PythonRequests Last Checkpoint: 14 minutes ago (autosaved) Logout File Edit View Insert Cell Kernel Widgets Help Not Trusted |Python 3 + Run C Markdown Use the GET /resources/authors/AUTHORID API -- to get details for a specific author (18 Points) http://www.penguinrandomhouse.biz/webservices/rest/#author Use the Penguin Random House API to do a GET request for the authorid found in the previous step. Include headers value of 'Accept": 'application/json' Print the Response text In [45]: M # INSERT GET USING AUTHORID API. PRINT RESPONSE TEXT Use json.loads to convert the text string into a Python dict/list Print the JSON using json.dumps with indent=4, sort_keys= True to make it easier to read (see Lab8) In [47]: ) # INSERT JSON. LOADS and JSON. DUMPS CODE Get data from the JSON ... Print the authorlastfirst value - Print the spotlight value In [49]: M # INSERT PRINT OF JSON 'authorlastfirst' and 'spotlight' VALUES Use the GET /resources/works API -- search for works (18 Points) http://www.penguinrandomhouse.biz/webservices/rest/#works Search for The Da Vinci Code Use the Penguin Random House API to do a GET works request Include search for work Da Vinci Code Include headers value of 'Accept": 'application/json' -Print the Response text In [51] : # INSERT GET WORKS WITH SEARCH & HEADERS. PRINT RESPONSE TEXTjupyter Lab9-PythonRequests Last Checkpoint: 14 minutes ago (autosaved) Logout File Edit View Insert Cell Kernel Widgets Help Not Trusted | Python 3 O + + Run CH Markdown Use json.loads to convert the text string into a Python dict/list -Print the JSON using json.dumps with indent=4, sort_keys=True to make it easier to read (see Lab8) In [ ]: ) # INSERT JSON. LOADS and JSON. DUMPS CODE Get data from the JSON .. - Get the workid value -Print the workid value In [ ]: ) # INSERT GET & PRINT OF JSON 'workid' VALUE Use the GET /resources/works/WORKID API -- to get details for a specific work (18 Points) http://www.penguinrandomhouse.biz/webservices/rest/#work - Use the Penguin Random House WORKID API to do a GET request Include search for the workid found in the previous step Include headers value of 'Accept": 'application/json' - Print the Response text In [ ]: ) # INSERT GET WORKID & PRINT RESPONSE TEXT Use json.loads to convert the text string into a Python dict/list -Print the JSON using json.dumps with indent=4, sort_keys=True to make it easier to read (see Lab8) In [ ]: ) # INSERT JSON. LOADS and JSON. DUMPS CODE Get data from the JSON ... - Print the authorweb value Print the onsaledate value Print the rgauthbio value In [ ] : ) # INSERT PRINT OF JSON 'authorweb', 'onsaledate' and 'rgauthbio' VALUESJupyter Lab9-PythonRequests Last Checkpoint: 15 minutes ago (autosaved) Logout File Edit View Insert Cell Kernel Widgets Help Not Trusted |Python 3 + Run C Markdown Use the GET /resources/titles API -- search for titles (18 Points) http://www.penguinrandomhouse.biz/webservices/rest/#titles Search by titles - ONLY get the first 4 (max=4) and use Dan Brown's authorid to limit it to his books - Use the Penguin Random House TITLES API to do a GET request Include start and max values to limit the titles to 4 - Include the authorid found in the previously (for Dan Brown) Include headers value of 'Accept': 'application/json' - Print the Response text In [ ]: M # INSERT GET TITLES WITH MAX 4 & AUTHORID & PRINT RESPONSE TEXT -Use json.loads to convert the text string into a Python dict/list - Print the JSON using json.dumps with indent=4, sort_keys=True to make it easier to read (see Lab8) In [ ]: # INSERT JSON. LOADS and JSON. DUMPS CODE Get data from the JSON to print the following values from each of the 4 titles returned: Print the author value Print the titleweb value -Print the subjectcategorydescription2 value - Print the isbn 13hyphenated value - Print the onsaledate value Print the formatname value - Print the priceusa value -Print the pricecanada value Print the pages value - Print a separator line '---------' for readability In [ ]: ) # Print the following elements from each of the 4 titles returned for i in range(4) : print (text_json[ ' title' ] [i] [' author' ]) print (text_json[ ' title' ][i][ 'titleweb' ]) print (text_json[ ' title' ][i][ ' subjectcategorydescription2' ]) print (text_json[ 'title' ][i][ 'isbn13hyphenated' ]) print (text_json[ ' title' ] [i] [ 'onsaledate' ]) print (text_json[ ' title' ] [i][ ' formatname' ]) print (text_json[ ' title' ][i][ 'priceusa' ]) print (text_json[ 'title' ][i][ 'pricecanada' ]) print (text_json[ ' title' ][i] [ 'pages' ]) print ("

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions