seaswalker / posts

0 stars 0 forks source link

Python请求接口脚本 #47

Open seaswalker opened 3 years ago

seaswalker commented 3 years ago
import requests
import json

name = '地球'
business = 1

# 对cookie进行编码必不可少
cookie = 'xaffa132131'.encode("utf-8")
url = 'http://service.com/modify'
header = {
    'Content-Type': 'application/json',
    'Cookie': cookie
}

data = {
    'business': business,
    'name': name
}

r = requests.post(url, headers=header, data=json.dumps(data))
print(r, r.text)