Ejemplo n.º 1
0
    def parse_data(cls, data):
        meta = Meta()
        meta.title = data['question']['title']
        meta.author = data['author']['name']
        meta.voteup = data['voteup_count']
        meta.original_url = API.format_url(
            'answer_link', question_id=data['question']['id'], answer_id=data['id'])

        meta.created_date = timer.timestamp_to_date(data['created_time'])
        meta.author_homepage = API.format_url(
            'author_homepage', user_id=data['author']['url_token'])

        meta.author_avatar_url = data['author']['avatar_url_template'].format(size='l')

        return meta, data.get('content')
Ejemplo n.º 2
0
def parse_answer(data):
    meta = Meta()

    meta.identity = data.get('id')
    meta.content = data.get('content')
    meta.voteup = data.get('voteup_count')
    meta.author = util.getvalue(data, 'author/name')
    meta.title = util.getvalue(data, 'question/title')
    meta.created_date = util.timestamp_to_date(data.get('created_time'))

    meta.author_homepage = core.ZhihuRequestsApi.get_with_identity(
        'AuthorHomePageUrl', util.getvalue(data, 'author/url_token'))

    meta.source_url = core.ZhihuRequestsApi.get_with_identity(
        'AnswerUrl', data.get('id'))
    meta.author_avatar_url = util.getvalue(
        data, 'author/avatar_url_template').format(size='l')

    return meta