根据cookie获取B站个人信息

简要描述

  • 根据cookie获取B站个人信息

请求URL

  • https://api.bilibili.com/x/web-interface/nav

请求方式

  • POST

请求头

参数名 必选 类型
referer string
user-agent(经测试,在获取cookie时也应获取对应的user-agent,若cookie和user-agent不对应可能导致获取不到数据) string
cookie string

请求示例

    headers = {  # 请求的头部
        "referer": "https://t.bilibili.com/",
        "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36 Edg/88.0.705.63",
        "cookie": "",
    }

返回示例

{
    "code": 0,
    "message": "0",
    "ttl": 1,
    "data": {
        "isLogin": true,
        "email_verified": 1,
        "face": "-------",
        "face_nft": 0,
        "face_nft_type": 0,
        "level_info": {
            "current_level": 5,
            "current_min": -------,
            "current_exp": -------,
            "next_exp": -------
        },
        "mid": -------,
        "mobile_verified": 1,
        "money": -------,
        "moral": -------,
        "official": {
            "role": 0,
            "title": "",
            "desc": "",
            "type": -1
        },
        "officialVerify": {
            "type": -1,
            "desc": ""
        },
        "pendant": {
            "pid": 0,
            "name": "",
            "image": "",
            "expire": 0,
            "image_enhance": "",
            "image_enhance_frame": ""
        },
        "scores": 0,
        "uname": "-------",
        "vipDueDate": 0,
        "vipStatus": 0,
        "vipType": 0,
        "vip_pay_type": 0,
        "vip_theme_type": 0,
        "vip_label": {
            "path": "",
            "text": "",
            "label_theme": "",
            "text_color": "",
            "bg_style": 0,
            "bg_color": "",
            "border_color": "",
            "use_img_label": true,
            "img_label_uri_hans": "",
            "img_label_uri_hant": "",
            "img_label_uri_hans_static": "-------",
            "img_label_uri_hant_static": "-------"
        },
        "vip_avatar_subscript": 0,
        "vip_nickname_color": "",
        "vip": {
            "type": 0,
            "status": 0,
            "due_date": 0,
            "vip_pay_type": 0,
            "theme_type": 0,
            "label": {
                "path": "",
                "text": "",
                "label_theme": "",
                "text_color": "",
                "bg_style": 0,
                "bg_color": "",
                "border_color": "",
                "use_img_label": true,
                "img_label_uri_hans": "",
                "img_label_uri_hant": "",
                "img_label_uri_hans_static": "-------",
                "img_label_uri_hant_static": "-------"
            },
            "avatar_subscript": 0,
            "nickname_color": "",
            "role": 0,
            "avatar_subscript_url": "",
            "tv_vip_status": 0,
            "tv_vip_pay_type": 0
        },
        "wallet": {
            "mid": -------,
            "bcoin_balance": 0,
            "coupon_balance": 0,
            "coupon_due_time": 0
        },
        "has_shop": false,
        "shop_url": "",
        "allowance_count": 0,
        "answer_status": 0,
        "is_senior_member": 0
    }
}

返回参数说明

参数名 类型 说明
face string 头像
current_level string 等级
current_min string 达到当前等级所需最小经验值
current_exp string 当前经验值
mid string uid
money string 硬币数
uname string 名称
posted @ 2022-06-17 20:07  梓宸3317  阅读(667)  评论(0)    收藏  举报