获取登录后的tokens使用
## CaseDemo
import unittest
from api_key_demo import ApiKeys
class CaseDemo(unittest.TestCase):
@classmethod
def setUpClass(cls) ->None:
cls.token = None
cls.api_key = ApiKeys()
def test_01_login(self):
url = "https://www.douban.com/"
data ={
'username': '',
'password': ''
}
res = self.api_key.do_post(url, json=data)
CaseDemo = res.json()['token']
def test_02_login(self):
header ={
'token':self.token
}
res1 = self.api_key.do_get("https://www.douban.com/", headers=header)
print(res1.text)
网友评论