-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay9_Library.py
More file actions
28 lines (20 loc) · 785 Bytes
/
Day9_Library.py
File metadata and controls
28 lines (20 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import requests
from terminaltables import AsciiTable
def get_books(author):
url = '''http://data.bn.org.pl/api/bibs.json?author={author}&%3Bkind=
ksi%C4%85%C5%BCka&fbclid=IwAR3LPbak_U4vrgQs-DpKhIaN35Wpqg1rQC3T7HVF-1sIy-BfK_aQb5ChDWY'''.format(
author=author)
response = requests.request(method="GET", url=url)
return response.json()
author = input("Give author: ")
response = get_books(author)
table_data = [['Tytuł', 'Gatunek', 'rok Publikacji']]
info = ["", "", ""]
for i in range(len(response["bibs"])):
info[0] = response["bibs"][i]["title"]
info[1] = response["bibs"][i]["genre"]
info[2] = response["bibs"][i]["publicationYear"]
table_data.append(info)
info = ["", "", ""]
table = AsciiTable(table_data)
print(table.table)