Beispiel #1
0
    def parse_data(cls, data):
        meta = Meta()

        meta.title = data['title']
        meta.author = data['author']['name']
        meta.voteup = data['voteup_count']
        meta.background = data['image_url']
        meta.original_url = API.format_url('article_link', article_id=data['id'])
        meta.created_date = timer.timestamp_to_date(data['created'])
        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')
Beispiel #2
0
def parse_article(data):
    meta = Meta()

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

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

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

    return meta