你好,鱼油!在Python中,你可以使用requests库来发送HTTP请求。下面是一个示例,展示如何构造一个类似你提供的GET请求:
import requests
url = "http://59.207.60.70:9001/elementsCheck/storey/deleteStorey"
params = {
"id": "622746"
}
headers = {
"Host": "59.207.60.70:9001",
"Connection": "keep-alive",
"Access-Control-Allow-Origin": "*",
"Accept": "application/json",
"Authorization": "axy1yodu7DkjtACbueZjRzEN3bxBM9O417PU7ncu",
"DeptCode": "143719",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36",
"Content-Type": "application/json;charset=utf-8",
"Referer": "http://59.207.60.70:9001/micro/gridCms/infoManage/roomArchives/list?current=1&pageSize=10",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,zh;q=0.9"
}
response = requests.get(url, headers=headers, params=params)
print(response.status_code)
print(response.json()) # 如果服务器返回的是JSON数据
确保你已经安装requests库,可以使用以下命令进行安装:
上述代码会发送一个GET请求,并将请求头和参数添加到请求中。你可以根据实际返回的数据格式,修改`response.json()`为`response.text()`来获取非JSON格式的数据。
如果需要发送POST请求,只需将`requests.get`改为`requests.post`即可。希望这个回答能帮到你!
以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。 |