def __init__(self, data): self.title = data['title'] self.author = '、'.join(data['author']) self.binding = data['binding'] self.publisher = data['publisher'] self.image = data['image'] self.price = '¥' + data['price'] if data['price'] else data['price'] self.isbn = get_isbn(data) self.pubdate = data['pubdate'] self.summary = data['summary'] self.pages = data['pages']
def persistence_yushu(cls, book): book_model = Book() book_model.set_attrs(book) # book_model.isbn = book['isbn13'] or book['isbn10'] book_model.isbn = get_isbn(book) book_model.image = book['images']['large'] # book_model.origin_url = book['url'] # book_model.score = book['rating']['average'] # book_model.tags = book['tags'] db.session.add(book_model) db.session.commit() return book_model
def __init__(self, data): # if not isinstance(data, dict):V # author = data.author # data = data.__dict__ # data['author'] = author self.title = data['title'] self.author = '、'.join(data['author']) self.binding = data['binding'] self.publisher = data['publisher'] self.image = data['image'] self.price = '¥' + data['price'] if data['price'] else data['price'] self.isbn = get_isbn(data) self.pubdate = data['pubdate'] self.summary = data['summary'] self.pages = data['pages']