#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Date    : 2021-01-06
# Author  : Yuanbo Zhao (chaojunction@gmail.com)


import requests
from pprint import pprint

url = 'https://aweme.snssdk.com/aweme/v1/user/profile/other/?sec_user_id=MS4wLjABAAAAI-lEgbXAy9AcrRR_ujh1DfyWRuh1ZjxLdzmjMD948KY&address_book_access=1&from=0&publish_video_strategy_type=2&user_avatar_shrink=188_188&user_cover_shrink=750_422&os_api=22&device_type=SM-G973N&ssmix=a&manifest_version_code=130901&dpi=320&uuid=351564422117622&app_name=aweme&version_name=13.9.0&ts=1609867109&cpu_support64=false&app_type=normal&appTheme=dark&ac=wifi&host_abi=armeabi-v7a&update_version_code=13909900&channel=tengxun_new&_rticket=1609867109171&device_platform=android&iid=1600542259283175&version_code=130900&cdid=5c48cb70-2eb7-4709-82a3-75929677122c&openudid=f795f21196fb5adf&device_id=1020000118778600&resolution=900*1600&os_version=5.1.1&language=zh&device_brand=samsung&aid=1128&mcc_mnc=46007'

headers = {
    'User-Agent': 'okhttp/3.10.0.1',
    'Host': 'aweme.snssdk.com',
    'Cookie': 'install_id=1600542259283175; ttreq=1$a7f704df58dca38069b5233aa3a0b655e1e4c322; passport_csrf_token=db847db33b9801101795918fb1b8e4fe; passport_csrf_token_default=db847db33b9801101795918fb1b8e4fe; MONITOR_WEB_ID=3ab9381e-4929-46c5-9aad-8f11d9256ec2; d_ticket=9d9c8fbcf98e4516f40582977a2db3e918ac2; multi_sids=4292146724602957%3Aa27781509ab61b477346e7f767bb2967; odin_tt=c646dcca3e6fc6f4cc11ba30d981296b4043b32a9d08de155662cee4ddff326413e7a3da45444cc94563caecf38cca81b9bcd121d6dc44d3aefb3eca3e03b315; n_mh=4Tm58DHuZyu6eu3sZZQlPoNTYvHGFXur4UnCsexlg-U; sid_guard=a27781509ab61b477346e7f767bb2967%7C1609866842%7C5184000%7CSat%2C+06-Mar-2021+17%3A14%3A02+GMT; uid_tt=91d02867df48fc0d742fb6c2c378674d; uid_tt_ss=91d02867df48fc0d742fb6c2c378674d; sid_tt=a27781509ab61b477346e7f767bb2967; sessionid=a27781509ab61b477346e7f767bb2967; sessionid_ss=a27781509ab61b477346e7f767bb2967',
    'tc_2021_now_client': '1609867751354',
    'passport-sdk-version': '18',
    'X-Tt-Token': '00a27781509ab61b477346e7f767bb296702bd23a6df845d5071031288397d234ca68403361d7cda0b797189ef14684543a93a6dad8cd887b19affac39294d038e9d7ea581666d81fa2d33d62b9274c4ce9ac-1.0.0',
    'sdk-version': '2',
    'X-SS-REQ-TICKET': '1609867109173',
    'X-Tyhon': 'J0pTj+9MaJjfa3q68nQlq9IFd4rzdnm+6H9IRbU=',
    'X-Khronos': '1609867109',
    'X-Gorgon': '04042071000081fc5fd208cbee119215bdbcd71a30f54598f0fd'
}

response = requests.get(url, headers=headers)
# pprint(response.json())
data = response.json()
if data['user']:
    user = data['user']
    user_info = {
        "昵称": user['nickname'],
        "个人认证": user['custom_verify'],
        "签名": user['signature'],
        "获赞数": user['total_favorited'],
        "粉丝数": user['follower_count'],
        "关注数": user['following_count'],
        "作品数": user['aweme_count'],
        "喜欢作品数": user['favoriting_count'],
        "所在城市": user['city']
    }
    pprint(user_info)

else:
    print('用户数据获取失败')


"""
{'extra': {'fatal_item_ids': [],
           'logid': '202101060144430101980650165E02A11E',
           'now': 1609868683000},
 'log_pb': {'impr_id': '202101060144430101980650165E02A11E'},
 'status_code': 0,
 'user': {'apple_account': 0,
          'avatar_168x168': {'height': 720,
                             'uri': '310e3000a130132511b54',
                             'url_list': ['https://p3-dy-ipv6.byteimg.com/310e3000a130132511b54~tplv-dy-shrink:188:188.webp?from=2956013662&s=PackSourceEnum_USER_PROFILE&se=true&sh=188_188&sc=avatar&l=202101060144430101980650165E02A11E',
                                          'https://p9-dy.byteimg.com/img/310e3000a130132511b54~c5_168x168.webp?from=2956013662&s=PackSourceEnum_USER_PROFILE&se=false&sh=&sc=avatar&l=202101060144430101980650165E02A11E',
                                          'https://p3-dy-ipv6.byteimg.com/img/310e3000a130132511b54~c5_168x168.webp?from=2956013662&s=PackSourceEnum_USER_PROFILE&se=false&sh=&sc=avatar&l=202101060144430101980650165E02A11E',
                                          'https://p29-dy.byteimg.com/img/310e3000a130132511b54~c5_168x168.webp?from=2956013662&s=PackSourceEnum_USER_PROFILE&se=false&sh=&sc=avatar&l=202101060144430101980650165E02A11E',
                                          'https://p9-dy.byteimg.com/img/310e3000a130132511b54~c5_168x168.jpeg?from=2956013662&s=PackSourceEnum_USER_PROFILE&se=false&sh=&sc=avatar&l=202101060144430101980650165E02A11E'],
                             'width': 720},
          'avatar_300x300': {'height': 720,
                             'uri': '310e3000a130132511b54',
                             'url_list': ['https://p3-dy-ipv6.byteimg.com/310e3000a130132511b54~tplv-dy-shrink:188:188.webp?from=2956013662&s=PackSourceEnum_USER_PROFILE&se=true&sh=188_188&sc=avatar&l=202101060144430101980650165E02A11E',
                                          'https://p5-dy-ipv6.byteimg.com/img/310e3000a130132511b54~c5_300x300.webp?from=2956013662&s=PackSourceEnum_USER_PROFILE&se=false&sh=&sc=avatar&l=202101060144430101980650165E02A11E',
                                          'https://p1-dy-ipv6.byteimg.com/img/310e3000a130132511b54~c5_300x300.webp?from=2956013662&s=PackSourceEnum_USER_PROFILE&se=false&sh=&sc=avatar&l=202101060144430101980650165E02A11E',
                                          'https://p3-dy-ipv6.byteimg.com/img/310e3000a130132511b54~c5_300x300.webp?from=2956013662&s=PackSourceEnum_USER_PROFILE&se=false&sh=&sc=avatar&l=202101060144430101980650165E02A11E',
                                          'https://p5-dy-ipv6.byteimg.com/img/310e3000a130132511b54~c5_300x300.jpeg?from=2956013662&s=PackSourceEnum_USER_PROFILE&se=false&sh=&sc=avatar&l=202101060144430101980650165E02A11E'],
                             'width': 720},
          'avatar_larger': {'height': 720,
                            'uri': '310e3000a130132511b54',
                            'url_list': ['https://p26-dy.byteimg.com/aweme/1080x1080/310e3000a130132511b54.webp?from=2956013662&s=PackSourceEnum_USER_PROFILE&se=false&sh=&sc=avatar&l=202101060144430101980650165E02A11E',
                                         'https://p6-dy-ipv6.byteimg.com/aweme/1080x1080/310e3000a130132511b54.webp?from=2956013662&s=PackSourceEnum_USER_PROFILE&se=false&sh=&sc=avatar&l=202101060144430101980650165E02A11E',
                                         'https://p5-dy-ipv6.byteimg.com/aweme/1080x1080/310e3000a130132511b54.webp?from=2956013662&s=PackSourceEnum_USER_PROFILE&se=false&sh=&sc=avatar&l=202101060144430101980650165E02A11E',
                                         'https://p26-dy.byteimg.com/aweme/1080x1080/310e3000a130132511b54.jpeg?from=2956013662&s=PackSourceEnum_USER_PROFILE&se=false&sh=&sc=avatar&l=202101060144430101980650165E02A11E'],
                            'width': 720},
          'avatar_medium': {'height': 720,
                            'uri': '310e3000a130132511b54',
                            'url_list': ['https://p6-dy-ipv6.byteimg.com/310e3000a130132511b54~tplv-dy-shrink:188:188.webp?from=2956013662&s=PackSourceEnum_USER_PROFILE&se=true&sh=188_188&sc=avatar&l=202101060144430101980650165E02A11E',
                                         'https://p9-dy.byteimg.com/aweme/720x720/310e3000a130132511b54.webp?from=2956013662&s=PackSourceEnum_USER_PROFILE&se=false&sh=&sc=avatar&l=202101060144430101980650165E02A11E',
                                         'https://p3-dy-ipv6.byteimg.com/aweme/720x720/310e3000a130132511b54.webp?from=2956013662&s=PackSourceEnum_USER_PROFILE&se=false&sh=&sc=avatar&l=202101060144430101980650165E02A11E',
                                         'https://p6-dy-ipv6.byteimg.com/aweme/720x720/310e3000a130132511b54.webp?from=2956013662&s=PackSourceEnum_USER_PROFILE&se=false&sh=&sc=avatar&l=202101060144430101980650165E02A11E',
                                         'https://p9-dy.byteimg.com/aweme/720x720/310e3000a130132511b54.jpeg?from=2956013662&s=PackSourceEnum_USER_PROFILE&se=false&sh=&sc=avatar&l=202101060144430101980650165E02A11E'],
                            'width': 720},
          'avatar_thumb': {'height': 720,
                           'uri': '310e3000a130132511b54',
                           'url_list': ['https://p3-dy-ipv6.byteimg.com/310e3000a130132511b54~tplv-dy-shrink:188:188.webp?from=2956013662&s=PackSourceEnum_USER_PROFILE&se=true&sh=188_188&sc=avatar&l=202101060144430101980650165E02A11E',
                                        'https://p9-dy.byteimg.com/aweme/100x100/310e3000a130132511b54.webp?from=2956013662&s=PackSourceEnum_USER_PROFILE&se=false&sh=&sc=avatar&l=202101060144430101980650165E02A11E',
                                        'https://p26-dy.byteimg.com/aweme/100x100/310e3000a130132511b54.webp?from=2956013662&s=PackSourceEnum_USER_PROFILE&se=false&sh=&sc=avatar&l=202101060144430101980650165E02A11E',
                                        'https://p29-dy.byteimg.com/aweme/100x100/310e3000a130132511b54.webp?from=2956013662&s=PackSourceEnum_USER_PROFILE&se=false&sh=&sc=avatar&l=202101060144430101980650165E02A11E',
                                        'https://p9-dy.byteimg.com/aweme/100x100/310e3000a130132511b54.jpeg?from=2956013662&s=PackSourceEnum_USER_PROFILE&se=false&sh=&sc=avatar&l=202101060144430101980650165E02A11E'],
                           'width': 720},
          'aweme_count': 221,
          'birthday': '2026-01-01',
          'birthday_hide_level': 0,
          'city': '武汉市',
          'commerce_info': {'challenge_list': [],
                            'head_image_list': None,
                            'offline_info_list': [],
                            'smart_phone_list': None,
                            'task_list': None},
          'commerce_user_info': {'ad_revenue_rits': None,
                                 'has_ads_entry': False,
                                 'show_star_atlas_cooperation': False,
                                 'star_atlas': 1},
          'commerce_user_level': 0,
          'country': '中国',
          'cover_colour': '#03997706',
          'cover_url': [{'uri': 'douyin-user-file/70488477613bec7d06dfd0243944086d',
                         'url_list': ['https://p26-dy.byteimg.com/douyin-user-file/70488477613bec7d06dfd0243944086d~tplv-dy-shrink:750:422.jpeg?from=2480802190&s=profile&se=true&sh=750_422&sc=cover&l=202101060144430101980650165E02A11E',
                                      'https://p3-dy-ipv6.byteimg.com/obj/douyin-user-file/70488477613bec7d06dfd0243944086d?from=2480802190&s=profile&se=false&sh=&sc=cover&l=202101060144430101980650165E02A11E',
                                      'https://p1-dy-ipv6.byteimg.com/obj/douyin-user-file/70488477613bec7d06dfd0243944086d?from=2480802190&s=profile&se=false&sh=&sc=cover&l=202101060144430101980650165E02A11E',
                                      'https://p26-dy.byteimg.com/obj/douyin-user-file/70488477613bec7d06dfd0243944086d?from=2480802190&s=profile&se=false&sh=&sc=cover&l=202101060144430101980650165E02A11E']},
                        {'uri': 'c8510002be9a3a61aad2',
                         'url_list': ['https://p3-dy-ipv6.byteimg.com/c8510002be9a3a61aad2~tplv-dy-shrink:750:422.jpeg?from=2480802190&s=profile&se=true&sh=750_422&sc=cover&l=202101060144430101980650165E02A11E',
                                      'https://p29-dy.byteimg.com/obj/c8510002be9a3a61aad2?from=2480802190&s=profile&se=false&sh=&sc=cover&l=202101060144430101980650165E02A11E',
                                      'https://p26-dy.byteimg.com/obj/c8510002be9a3a61aad2?from=2480802190&s=profile&se=false&sh=&sc=cover&l=202101060144430101980650165E02A11E',
                                      'https://p3-dy-ipv6.byteimg.com/obj/c8510002be9a3a61aad2?from=2480802190&s=profile&se=false&sh=&sc=cover&l=202101060144430101980650165E02A11E']}],
          'custom_verify': '人气视频创作者',
          'district': '汉阳区',
          'dongtai_count': 223,
          'enterprise_user_info': '{"commerce_info":{"offline_info_list":[],"challenge_list":[],"task_list":null,"head_image_list":null,"smart_phone_list":null},"homepage_bottom_toast":[],"permissions":[{"Id":3,"Key":"ItemShop","Name":"视频电商","AppId":1128,"Status":1,"Extra":null,"Customization":null,"Parent":0,"Actions":null},{"Id":5,"Key":"UserShop","Name":"个人橱窗","AppId":1128,"Status":1,"Extra":null,"Customization":null,"Parent":0,"Actions":null},{"Id":4,"Key":"LiveShop","Name":"直播电商","AppId":1128,"Status":1,"Extra":null,"Customization":null,"Parent":0,"Actions":null}]}',
          'enterprise_verify_reason': '',
          'favoriting_count': 0,
          'follow_status': 0,
          'follower_count': 20403272,
          'follower_status': 0,
          'followers_detail': [{'app_name': 'aweme',
                                'apple_id': '1142110895',
                                'download_url': 'https://d.douyin.com/JsvN/',
                                'fans_count': 20403272,
                                'icon': 'http://p3.pstatp.com/origin/50ec00079b64de2050dc',
                                'name': '抖音',
                                'open_url': 'snssdk1128://user/profile/60043717321?',
                                'package_name': 'com.ss.android.ugc.aweme'},
                               {'app_name': 'news_article',
                                'apple_id': '529092160',
                                'download_url': 'https://d.toutiao.com/YjjY/',
                                'fans_count': 0,
                                'icon': 'http://p3.pstatp.com/origin/50ed00079a1b6b8d1fb1',
                                'name': '头条',
                                'open_url': 'snssdk143://profile?uid=0',
                                'package_name': 'com.ss.android.article.news'},
                               {'app_name': 'live_stream',
                                'apple_id': '1086047750',
                                'download_url': 'http://d.huoshanzhibo.com/eFvB/',
                                'fans_count': 0,
                                'icon': 'http://p3.pstatp.com/origin/2ea5c000abe106154adef',
                                'name': '抖音火山版',
                                'open_url': 'snssdk1112://profile?id=0',
                                'package_name': 'com.ss.android.ugc.live'}],
          'following_count': 52,
          'forward_count': 2,
          'gender': 2,
          'general_permission': {'following_follower_list_toast': 1},
          'ins_id': '',
          'is_activity_user': False,
          'is_block': False,
          'is_blocked': False,
          'is_effect_artist': False,
          'is_gov_media_vip': False,
          'is_mix_user': False,
          'is_star': False,
          'life_story_block': {'life_story_block': False},
          'live_commerce': True,
          'message_chat_entry': True,
          'mplatform_followers_count': 20403272,
          'nickname': '小橙子',
          'original_musician': {'digg_count': 0,
                                'music_count': 0,
                                'music_used_count': 0},
          'profile_tab_type': 0,
          'province': '湖北省',
          'r_fans_group_info': {},
          'recommend_reason_relation': '',
          'recommend_user_reason_source': 0,
          'room_id': 0,
          'school_name': '',
          'sec_uid': 'MS4wLjABAAAAI-lEgbXAy9AcrRR_ujh1DfyWRuh1ZjxLdzmjMD948KY',
          'secret': 0,
          'share_info': {'bool_persist': 1,
                         'share_desc': '在抖音，记录美好生活！',
                         'share_image_url': {'url_list': None},
                         'share_qrcode_url': {'uri': '216a0023aa35c71d4381',
                                              'url_list': ['https://p26-dy.byteimg.com/obj/216a0023aa35c71d4381',
                                                           'https://p1-dy-ipv6.byteimg.com/obj/216a0023aa35c71d4381',
                                                           'https://p29-dy.byteimg.com/obj/216a0023aa35c71d4381']},
                         'share_title': '快来加入抖音，让你发现最有趣的我！',
                         'share_url': 'www.iesdouyin.com/share/user/60043717321?u_code=4bdmmmcb4hl6&did=1020000118778600&iid=1600542259283175&sec_uid=MS4wLjABAAAAI-lEgbXAy9AcrRR_ujh1DfyWRuh1ZjxLdzmjMD948KY',
                         'share_weibo_desc': '在抖音，记录美好生活！'},
          'shop_micro_app': '',
          'short_id': '13632088',
          'show_favorite_list': True,
          'signature': '同款在橱窗👆🏻\n'
                       '——————————————————\n'
                       '承蒙厚爱 万分感激🙏🏻\n'
                       '视频均为自己创作 未签约 不直播\n'
                       '🍑 倾橙国风工作室（视频同款）\n'
                       '工作❤ orangelaby',
          'signature_language': 'zh',
          'sync_to_toutiao': 0,
          'tab_settings': {'private_tab': {'private_tab_style': 1,
                                           'show_private_tab': False}},
          'total_favorited': 270438683,
          'twitter_id': '',
          'twitter_name': '',
          'uid': '60043717321',
          'unique_id': '',
          'urge_detail': {'user_urged': 0},
          'user_not_show': 0,
          'verification_type': 1,
          'video_cover': {},
          'video_icon': {'height': 720,
                         'uri': '',
                         'url_list': [],
                         'width': 720},
          'watch_status': False,
          'white_cover_url': [{'uri': 'douyin-user-file/70488477613bec7d06dfd0243944086d',
                               'url_list': ['https://p26-dy.byteimg.com/douyin-user-file/70488477613bec7d06dfd0243944086d~tplv-dy-shrink:750:422.jpeg?from=2480802190&s=profile&se=true&sh=750_422&sc=cover&l=202101060144430101980650165E02A11E',
                                            'https://p3-dy-ipv6.byteimg.com/obj/douyin-user-file/70488477613bec7d06dfd0243944086d?from=2480802190&s=profile&se=false&sh=&sc=cover&l=202101060144430101980650165E02A11E',
                                            'https://p1-dy-ipv6.byteimg.com/obj/douyin-user-file/70488477613bec7d06dfd0243944086d?from=2480802190&s=profile&se=false&sh=&sc=cover&l=202101060144430101980650165E02A11E',
                                            'https://p26-dy.byteimg.com/obj/douyin-user-file/70488477613bec7d06dfd0243944086d?from=2480802190&s=profile&se=false&sh=&sc=cover&l=202101060144430101980650165E02A11E']},
                              {'uri': '318f1000413827e122102',
                               'url_list': ['https://p6-dy-ipv6.byteimg.com/318f1000413827e122102~tplv-dy-shrink:750:422.jpeg?from=2480802190&s=profile&se=true&sh=750_422&sc=cover&l=202101060144430101980650165E02A11E',
                                            'https://p3-dy-ipv6.byteimg.com/obj/318f1000413827e122102?from=2480802190&s=profile&se=false&sh=&sc=cover&l=202101060144430101980650165E02A11E',
                                            'https://p1-dy-ipv6.byteimg.com/obj/318f1000413827e122102?from=2480802190&s=profile&se=false&sh=&sc=cover&l=202101060144430101980650165E02A11E',
                                            'https://p29-dy.byteimg.com/obj/318f1000413827e122102?from=2480802190&s=profile&se=false&sh=&sc=cover&l=202101060144430101980650165E02A11E']}],
          'with_commerce_enterprise_tab_entry': False,
          'with_commerce_entry': True,
          'with_fusion_shop_entry': True,
          'with_new_goods': False,
          'youtube_channel_id': '',
          'youtube_channel_title': ''}}
[Finished in 0.8s]
"""