学习记录:python get/post接口测试2021-01-02

'''
利用requests 进行get post的接口请求
#post请求
# 注意点: post提交方式有两个传参方式,针对不同的content-type, 务必要指定接口是哪个类型,表单提交还是json提交
# Content-Type: application/x-www-form-urlencoded
#requests.post("url", data=data)
# Content-Type: application/json
# requests.post("url", json=data)

headers = {
    #请求头内容
    "":""
}
data = {
    #请求参数内容
    "":""
}
'''


'''
#首页分类列表
import requests

response = requests.get('https://api.xdclass.net/pub/api/v1/web/all_category')

print(response)
print(response.text)
print(response.content)

'''

'''
#视频卡片

import requests

response = requests.get('https://api.xdclass.net/pub/api/v1/web/index_card')

print(response)
print(response.text)

'''

'''
#视频详情
import requests
data = {'video_id':'53'}
response = requests.get('https://api.xdclass.net/pub/api/v1/web/video_detail',data)

print(response)
print(response.text)
'''
#https://api.xdclass.net

'''
#用户登录
import requests

data = {
    'phone':'13610fews',
    'pwd':'few0426.'
}

response = requests.post('https://api.xdclass.net/pub/api/v1/web/web_login', data=data)

print(response)
print(response.text)
'''

#用户个人信息


'''
import requests

headers = {
    "token":"xdclasseyJhbGciOiJIUzfeJ9.eyJzdWIiOiJ4ZGNsYXNzIiwicm9sZXMiOiIxIiwiaW1nIjoiaHR0cHM6Ly94ZC12aWRlby1wYy1pbWcub3NzLWNuLWJlaWppbmcuYWxpeXVuY3MuY29tL3hkY2xhc3NfcHJvL2RlZmF1bHQvaGVhZF9pbWcvMTYuanBlZyIsImlkIjo2NzgyNjczLCJuYW1lIjoi5p6X5L-K5p2w6KOk5a2Q5o6J5LqGIiwiaWF0IjoxNjA5NTY3ODUwLCJleHAiOjE2MTAxNzI2NTB9.bdhNdBsT_XvtPpzYWZQETFut75taikvp40pz6gdR4wc"
}

response = requests.get('https://api.xdclass.net/pub/api/v1/web/user_info', headers=headers)

print(response)
print(response.text)
'''

'''
#我的订单
import requests

headers = {
    "token":"xdclasseyJhbGciOiJIUzI1NiJfeWIiOiJ4ZGNsYXNzIiwicm9sZXMiOiIxIiwiaW1nIjoiaHR0cHM6Ly94ZC12aWRlby1wYy1pbWcub3NzLWNuLWJlaWppbmcuYWxpeXVuY3MuY29tL3hkY2xhc3NfcHJvL2RlZmF1bHQvaGVhZF9pbWcvMTYuanBlZyIsImlkIjo2NzgyNjczLCJuYW1lIjoi5p6X5L-K5p2w6KOk5a2Q5o6J5LqGIiwiaWF0IjoxNjA5NTY3ODUwLCJleHAiOjE2MTAxNzI2NTB9.bdhNdBsT_XvtPpzYWZQETFut75taikvp40pz6gdR4wc"
}

response = requests.get('https://api.xdclass.net/user/api/v1/order/find_orders', headers=headers)

print(response)
print(response.text)

'''

'''
#新增收藏

import requests

headers = {"token":"xdclasseyJhbGciOfezI1NiJ9.eyJzdWIiOiJ4ZGNsYXNzIiwicm9sZXMiOiIxIiwiaW1nIjoiaHR0cHM6Ly94ZC12aWRlby1wYy1pbWcub3NzLWNuLWJlaWppbmcuYWxpeXVuY3MuY29tL3hkY2xhc3NfcHJvL2RlZmF1bHQvaGVhZF9pbWcvMTYuanBlZyIsImlkIjo2NzgyNjczLCJuYW1lIjoi5p6X5L-K5p2w6KOk5a2Q5o6J5LqGIiwiaWF0IjoxNjA5NTcwMDE0LCJleHAiOjE2MTAxNzQ4MTR9.ceaFumN9t5wMDtCrk6-NBofEFKQW_ItRbkBCSU_29og"}
 
response = requests.post('https://api.xdclass.net/user/api/v1/favorite/save', data={"video_id":45}, headers=headers)

print(response)
print(response.text)
'''

'''
#我的收藏

import requests

headers = {
    "token":"xdclasseyJhbGciOiJIUzI1NiJfezdWIiOiJ4ZGNsYXNzIiwicm9sZXMiOiIxIiwiaW1nIjoiaHR0cHM6Ly94ZC12aWRlby1wYy1pbWcub3NzLWNuLWJlaWppbmcuYWxpeXVuY3MuY29tL3hkY2xhc3NfcHJvL2RlZmF1bHQvaGVhZF9pbWcvMTYuanBlZyIsImlkIjo2NzgyNjczLCJuYW1lIjoi5p6X5L-K5p2w6KOk5a2Q5o6J5LqGIiwiaWF0IjoxNjA5NTcwMDE0LCJleHAiOjE2MTAxNzQ4MTR9.ceaFumN9t5wMDtCrk6-NBofEFKQW_ItRbkBCSU_29og"
}

response = requests.get('https://api.xdclass.net/user/api/v1/favorite/page', headers=headers)

print(response)
print(response.text)
'''

猜你喜欢

转载自blog.csdn.net/qq_26086231/article/details/112098859