File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 11import requests
22
33endpoint = "https://www.googleapis.com/books/v1/volumes"
4- params = {"q" : "moby dick" , "maxResults" : 3 }
54
5+ # Define the search term you want to use.
6+ query = "moby dick"
7+
8+ # In the query parameters you can define:
9+ # 1. The number of books to return using the `maxResults` parameter.
10+ # 2. The query term to search for using the `q` parameter.
11+ params = {"q" : query , "maxResults" : 3 }
12+
13+ # The response will contain a list of books that match your query.
614response = requests .get (endpoint , params = params ).json ()
715for book in response ["items" ]:
16+ # In order to fetch the title, published date and description, you first need to fetch the volume.
817 volume = book ["volumeInfo" ]
18+
19+ # You can fetch these and other attributes from the book using the specific volume
920 title = volume ["title" ]
1021 published = volume ["publishedDate" ]
1122 description = volume ["description" ]
You can’t perform that action at this time.
0 commit comments