Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -45,7 +45,7 @@ def search_for_books(author: str) -> list[dict[str,str]]:
|
|
| 45 |
"""
|
| 46 |
|
| 47 |
max_pages = 5
|
| 48 |
-
counter =
|
| 49 |
try:
|
| 50 |
params = {"search": author}
|
| 51 |
base_url = 'https://gutendex.com/books'
|
|
@@ -54,7 +54,7 @@ def search_for_books(author: str) -> list[dict[str,str]]:
|
|
| 54 |
json_data = response.json()
|
| 55 |
|
| 56 |
results = []
|
| 57 |
-
while
|
| 58 |
print(counter)
|
| 59 |
|
| 60 |
for book in json_data['results']:
|
|
@@ -67,7 +67,7 @@ def search_for_books(author: str) -> list[dict[str,str]]:
|
|
| 67 |
results.append(book_info)
|
| 68 |
|
| 69 |
counter+=1
|
| 70 |
-
if
|
| 71 |
break
|
| 72 |
response = requests.get(json_data['next'])
|
| 73 |
json_data = response.json()
|
|
|
|
| 45 |
"""
|
| 46 |
|
| 47 |
max_pages = 5
|
| 48 |
+
counter = 1
|
| 49 |
try:
|
| 50 |
params = {"search": author}
|
| 51 |
base_url = 'https://gutendex.com/books'
|
|
|
|
| 54 |
json_data = response.json()
|
| 55 |
|
| 56 |
results = []
|
| 57 |
+
while counter < max_pages:
|
| 58 |
print(counter)
|
| 59 |
|
| 60 |
for book in json_data['results']:
|
|
|
|
| 67 |
results.append(book_info)
|
| 68 |
|
| 69 |
counter+=1
|
| 70 |
+
if json_data['next'] is None:
|
| 71 |
break
|
| 72 |
response = requests.get(json_data['next'])
|
| 73 |
json_data = response.json()
|