请求
# -*- coding: utf-8 -*- # @Time : 2021/9/17 14:00 # @Author : Hunk # @Email : seven922858@163.com # @Software: VScode import requests import json from urllib import parse # 定义请求header HEADERS = {'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8', 'Key': '332213fa4a9d4288b5668ddd9'} # 定义请求地址 url = "https://api.newrank.cn/api/sync/weibo/trend" # 通过字典方式定义请求body FormData = {"from": '2018-07-18 16:00:00', "to": '2018-07-18 18:00:00', "page": 1, "size": 1} # 字典转换k1=v1 & k2=v2 模式 data = parse.urlencode(FormData) # 请求方式 res = requests.post(url=url, headers=HEADERS, data=data) # content = json.loads(content) print(res.text) print(res.headers['Content-Type']) print(res.headers)