|
|
@@ -1,39 +1,37 @@
|
|
|
import requests
|
|
|
|
|
|
-# 基础 URL
|
|
|
-base_url = 'http://192.168.31.243:7745/api/cards/card_list'
|
|
|
-
|
|
|
-# 查询参数 (query parameters)
|
|
|
-params = {
|
|
|
- 'skip': 0,
|
|
|
- 'limit': 100
|
|
|
-}
|
|
|
-
|
|
|
-# 请求头 (headers)
|
|
|
-headers = {
|
|
|
- 'accept': 'application/json'
|
|
|
-}
|
|
|
-
|
|
|
-try:
|
|
|
- # 发送 GET 请求
|
|
|
- response = requests.get(base_url, params=params, headers=headers)
|
|
|
-
|
|
|
- # 检查响应状态码
|
|
|
- response.raise_for_status()
|
|
|
-
|
|
|
- # 打印响应内容 (JSON格式)
|
|
|
- data = response.json()
|
|
|
- print("Success! Response Data:")
|
|
|
- print(data)
|
|
|
-
|
|
|
- # 打印状态码
|
|
|
- print(f"Status Code: {response.status_code}")
|
|
|
-
|
|
|
-except requests.exceptions.HTTPError as errh:
|
|
|
- print(f"Http Error: {errh}")
|
|
|
-except requests.exceptions.ConnectionError as errc:
|
|
|
- print(f"Error Connecting: {errc}")
|
|
|
-except requests.exceptions.Timeout as errt:
|
|
|
- print(f"Timeout Error: {errt}")
|
|
|
-except requests.exceptions.RequestException as err:
|
|
|
- print(f"An Error Occurred: {err}")
|
|
|
+
|
|
|
+base_url = 'http://192.168.31.243:7745/api/cards/query/3'
|
|
|
+
|
|
|
+def send(url):
|
|
|
+ # 请求头 (headers)
|
|
|
+ headers = {
|
|
|
+ 'accept': 'application/json'
|
|
|
+ }
|
|
|
+
|
|
|
+ try:
|
|
|
+ # 发送 GET 请求
|
|
|
+ response = requests.get(base_url, headers=headers)
|
|
|
+
|
|
|
+ # 检查响应状态码
|
|
|
+ response.raise_for_status()
|
|
|
+
|
|
|
+ # 打印响应内容 (JSON格式)
|
|
|
+ data = response.json()
|
|
|
+ print("Success! Response Data:")
|
|
|
+ print(data)
|
|
|
+
|
|
|
+ # 打印状态码
|
|
|
+ print(f"Status Code: {response.status_code}")
|
|
|
+
|
|
|
+ except requests.exceptions.HTTPError as errh:
|
|
|
+ print(f"Http Error: {errh}")
|
|
|
+ except requests.exceptions.ConnectionError as errc:
|
|
|
+ print(f"Error Connecting: {errc}")
|
|
|
+ except requests.exceptions.Timeout as errt:
|
|
|
+ print(f"Timeout Error: {errt}")
|
|
|
+ except requests.exceptions.RequestException as err:
|
|
|
+ print(f"An Error Occurred: {err}")
|
|
|
+
|
|
|
+if __name__ == '__main__':
|
|
|
+ send(base_url)
|