抖音的直播视频录屏

# -*- coding: utf-8 -*-
 
import requests
import json, os
import time
import sys
from pathlib import Path
import traceback
import urllib.request
import random
import multiprocessing
 
# 获取登录后的cookie
def get_cookies(username,password):
    print("get_cookies")
    headers = {
        'Host': 'api-service.chanmama.com',
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0',
        'Accept': 'application/json, text/plain, */*',
        'Accept-Language': 'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
        'Accept-Encoding': 'gzip, deflate, br',
        'Referer': 'https://www.chanmama.com/login',
        'Content-Type': 'application/json;charset=utf-8',
        'X-Client-Id': '3057153329',
        #'Content-Length': '130',
        'Origin': 'https://www.chanmama.com',
        'Connection': 'keep-alive',
        'Cookie': 'Qs_lvt_411649=1645779886%2C1646012504%2C1646043451%2C1646100509%2C1646187120; Qs_pv_411649=4463430239281573000%2C900198088675931400%2C941538611317045000%2C3144867226959896600%2C16376944367739524; CMM_A_C_ID=09868efa-9605-11ec-adbb-0abe4946c76b; Hm_lvt_1f19c27e7e3e3255a5c79248a7f4bdf1=1645779886; Hm_lpvt_1f19c27e7e3e3255a5c79248a7f4bdf1=1646117927',
        'Sec-Fetch-Dest': 'empty',
        'Sec-Fetch-Mode': 'cors',
        'Sec-Fetch-Site': 'same-site',
        'TE': 'trailers'
    }
    filepath = Path.cwd().joinpath('token.json')
    if not filepath.exists():
        # 登录页面
        downlod_url = 'https://api-service.chanmama.com/v1/access/token'
        # 时间戳,先弄成整数型的,再弄成字符串
        timeStamp = str(int(time.time()))
        # 发起请求时携带的参数
        data = {
            'appId': '10000',
            'password': password,
            'timeStamp': timeStamp,
            'username': username,
        }
        print (data)
        # 对参数json化一下
        data = json.dumps(data)
      

你可能感兴趣的:(json,java,python)