I'd like to do is render/display isbn and work_ratings_count values on bookdetail.html
res output is:
{'books': [{'id': 29207858, 'isbn': '1632168146', 'isbn13': '9781632168146', 'ratings_count': 0, 'reviews_count': 2, 'text_reviews_count': 0, 'work_ratings_count': 28, 'work_reviews_count': 123, 'work_text_reviews_count': 10, 'average_rating': '4.07'}]}
code:
import requests, json
res= requests.get("https://www.goodreads.com/book/review_counts.json", params={"key": "xxx", "isbns": "9781632168146"})
JS = res.json()
bs = json.loads(JS)
print(bs.get['isbn'])
You might make things easier on yourself if you set up your data differently. Why not use nested dictionaries?
nested_dict = {"book": {"ISBN": 0000, "Num": 0001}, "book2": {"ISBN": 0000, "Num": 0001}}
Then to print you can call the key/value as:
nested_dict["book2"]["ISBN"]
Hope this helped, if I misinterpreted your question let me know.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.