38 lines
814 B
Python
38 lines
814 B
Python
# -*- encoding:utf-8 -*-
|
|
|
|
'''
|
|
@Author : dingjiawen
|
|
@Date : 2023/12/15 16:17
|
|
@Usage :
|
|
@Desc :
|
|
'''
|
|
|
|
import requests
|
|
from urllib.parse import urljoin
|
|
|
|
BASE_URL = 'https://login3.scrape.center/'
|
|
LOGIN_URL = urljoin(BASE_URL, '/api/login')
|
|
INDEX_URL = urljoin(BASE_URL, '/api/book')
|
|
USERNAME = 'admin'
|
|
PASSWORD = 'admin'
|
|
|
|
response_login = requests.post(LOGIN_URL, json={
|
|
'username': USERNAME,
|
|
'password': PASSWORD
|
|
})
|
|
data = response_login.json()
|
|
print('Response JSON', data)
|
|
jwt = data.get('token')
|
|
print('JWT', jwt)
|
|
|
|
headers = {
|
|
'Authorization': f'jwt {jwt}'
|
|
}
|
|
response_index = requests.get(INDEX_URL, params={
|
|
'limit': 18,
|
|
'offset': 0
|
|
}, headers=headers)
|
|
print('Response Status', response_index.status_code)
|
|
print('Response URL', response_index.url)
|
|
print('Response Data', response_index.json())
|