使用禅道做API测试踩坑记录1

# coding:utf-8
import requests

host = 'http://192.168.75.175'

url = host + '/zentao/user-login.html'


req = requests.get(url)

print(req.headers)



h1 = {
"Accept": "application/json, text/javascript, */*; q=0.01",
"X-Requested-With": "XMLHttpRequest",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36",
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"Referer": "http://192.168.75.175/zentao/user-login.html",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,lb;q=0.7"
}


data = {
    'account': 'admin',
    'password': 'qazwsx123',
    'referer': host+ '/zentao/',
    'keepLogin': 1
}

r = requests.post(url, data=data, headers=h1)

print(r.headers)

以上为脚本;

1 加载登录页面

2 使用账号登录

以此方式获取到的cookie与手动操作chrome获取的cookie样式完全一样,但是

脚本不能不到文件,而使用chrome中的cookie则可以,真是奇哉怪哉!!!

 

你可能感兴趣的:(使用禅道做API测试踩坑记录1)