Beispiel #1
0
def get_book_message(request,book_name):
    '''
    get book message from douban api
    '''
    rapi = RequestService_douban()
    book_message_dict = {}
    book_message_for_xml = {}

    book_message_dict = rapi.search_books(unicode(book_name).encode('utf-8'))
    
    book_message_for_xml.update({'title':book_message_dict['books'][0]['title']})
    book_message_for_xml.update({'description':book_message_dict['books'][0]['summary']})
    book_message_for_xml.update({'picture_url':book_message_dict['books'][0]['images']['large']})
    # book id now is ISBN
    book_message_for_xml.update({'book_id':str(book_message_dict['books'][0]['isbn13'])})

    return book_message_for_xml
Beispiel #2
0
def get_books_by_offset(request,search_string='百年孤独',is_offset=0,is_gession=0):
    '''
        get books by offset
    '''
    if not int(is_offset):
        request.session['next_offset'] = 0
        if int(is_gession):
            limit = 3
        else:
            limit = 10
    else:
        request.session['next_offset'] += 10
        limit = 10
    
    rapi = RequestService_douban()
    book_message_dict = {}

    book_message_dict = rapi.search_books(unicode(search_string).encode('utf-8'),offset=request.session['next_offset'],limit=limit)
    
    return book_message_dict