Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is what I have now for the previous questions. Below are the rest of the questions: Below are the URLs that I used for

This is what I have now for the previous questions.

image text in transcribed

Below are the rest of the questions:

image text in transcribed

Below are the URLs that I used for the questions:

Books

You can request data for a particular book (here we are requesting information for the book with ID 1):

http://www.anapioficeandfire.com/api/books/1 

You can request to get a list of all the book data:

http://www.anapioficeandfire.com/api/books 

Or you can filter the list of books by name or date. For example:

 http://www.anapioficeandfire.com/api/books?name=A Dance with Dragons

Characters

Similarly you can request data for a particular character (here we are requesting information for the character with id 823):

http://www.anapioficeandfire.com/api/characters/823 

You can request to get a list of all the data objects for all the characters:

http://www.anapioficeandfire.com/api/characters 

Or you can filter the list by many different fields including name, gender, culture, year of birth or death, or if the character is still alive. For Example:

http://www.anapioficeandfire.com/api/characters?name=Eddard Stark

Houses

Finally, you can get information about houses (for those who arent familiar with the shows/books - houses is the series name for dynastic families.). A single house:

http://www.anapioficeandfire.com/api/houses/362 

A list of all houses:

http://www.anapioficeandfire.com/api/houses 

Or you may filter the list of houses by many criteria. For example:

http://www.anapioficeandfire.com/api/houses?region=The North 

import requests import re import time def getGOTObject (objectType, objectID): #the result is different from the sample in lab77?? getGOTObject should check the response status_code. If its 200 (meaning that the query worked) getGOTObject should return the parsed JSON data.'" url-"http://www.anapioficeandfire.com/api?" + objectType+"/" str (objectID) responserequests.get(url) if response. status_code = 200: return response.json() else raise Exception("Response Error 404") def getGOTObjects (objectType, filterParameter-'") #urL = "http://www , anap10ficeand fire.com/api/" + objectType + "/" + str(1) url- "http://www.anap?of iceandfire.com apl houses?region-The North". while url!-'' responserequests.get(url) time.sleep(.1) if response.status_code200: curText-curText +response.text linksStr-response.headers['link'] url getNextPage(linksStr) else: break return curlext def getNextPage(linksStr): linkList linksStr.split(",") for item in linkList: if re.findall('([A)" ', item) [0] next' return re.findall('(I"]*)>', item) [0] return ' import requests import re import time def getGOTObject (objectType, objectID): #the result is different from the sample in lab77?? getGOTObject should check the response status_code. If its 200 (meaning that the query worked) getGOTObject should return the parsed JSON data.'" url-"http://www.anapioficeandfire.com/api?" + objectType+"/" str (objectID) responserequests.get(url) if response. status_code = 200: return response.json() else raise Exception("Response Error 404") def getGOTObjects (objectType, filterParameter-'") #urL = "http://www , anap10ficeand fire.com/api/" + objectType + "/" + str(1) url- "http://www.anap?of iceandfire.com apl houses?region-The North". while url!-'' responserequests.get(url) time.sleep(.1) if response.status_code200: curText-curText +response.text linksStr-response.headers['link'] url getNextPage(linksStr) else: break return curlext def getNextPage(linksStr): linkList linksStr.split(",") for item in linkList: if re.findall('([A)" ', item) [0] next' return re.findall('(I"]*)>', item) [0] return

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

Database Processing

Authors: David M. Kroenke, David Auer

11th Edition

B003Y7CIBU, 978-0132302678

More Books

Students also viewed these Databases questions