Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -50,11 +50,13 @@ def search_for_books(author: str) -> list[dict[str,str]]:
|
|
| 50 |
params = {"search": author}
|
| 51 |
base_url = 'https://gutendex.com/books'
|
| 52 |
|
| 53 |
-
|
|
|
|
|
|
|
| 54 |
results = []
|
| 55 |
-
while json_data['next']
|
| 56 |
-
|
| 57 |
-
|
| 58 |
for book in json_data['results']:
|
| 59 |
book_info = {
|
| 60 |
'title': book['title'],
|
|
@@ -65,6 +67,10 @@ def search_for_books(author: str) -> list[dict[str,str]]:
|
|
| 65 |
results.append(book_info)
|
| 66 |
|
| 67 |
counter+=1
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
return results
|
| 70 |
|
|
|
|
| 50 |
params = {"search": author}
|
| 51 |
base_url = 'https://gutendex.com/books'
|
| 52 |
|
| 53 |
+
response = requests.get(base_url, params=params)
|
| 54 |
+
json_data = response.json()
|
| 55 |
+
|
| 56 |
results = []
|
| 57 |
+
while json_data['next']:
|
| 58 |
+
print(counter)
|
| 59 |
+
|
| 60 |
for book in json_data['results']:
|
| 61 |
book_info = {
|
| 62 |
'title': book['title'],
|
|
|
|
| 67 |
results.append(book_info)
|
| 68 |
|
| 69 |
counter+=1
|
| 70 |
+
if counter >= max_pages:
|
| 71 |
+
break
|
| 72 |
+
response = requests.get(json_data['next'])
|
| 73 |
+
json_data = response.json()
|
| 74 |
|
| 75 |
return results
|
| 76 |
|