python之requests

GET
python 复制代码
import requests

url ='https://finance.pae.baidu.com/vapi/stockshort'
params = {'code':'09888', 'market':'hk', 'finClientType':'pc' }
headers = {'User-Agent': 'Mozilla/5.0'}

response = requests.get(url, params=params, headers=headers)

print(response.status_code)
print(response.text)
POST
python 复制代码
# 表单格式
import requests

url = 'https://example.com/api'
data = {'key1': 'value1', 'key2': 'value2'}  # 表单数据

response = requests.post(url, data=data)

print(response.status_code)
print(response.json())
python 复制代码
# json格式
import requests

url = 'https://example.com/api'
json_data = {'key1': 'value1', 'key2': 'value2'}  # JSON 数据
headers = {'Content-Type': 'application/json'}

response = requests.post(url, json=data, headers=headers)

print(response.status_code)
print(response.json())
相关推荐
再吃一根胡萝卜31 分钟前
Redis 都有哪些用处?都会用在什么地方?
后端
再吃一根胡萝卜39 分钟前
分布式与分布式锁:从访问量到数据一致性
后端
再吃一根胡萝卜41 分钟前
分库分表:为什么我不建议一上来就分表
后端
再吃一根胡萝卜41 分钟前
MySQL 慢查询优化:从定位到根治的完整思路
后端
Nturmoils2 小时前
订单查询丢数据,查了半天原来是 WHERE 惹的祸
数据库·后端
叫我Paul就好2 小时前
自从用上 Agents View 之后, 我的心力交瘁感消失了
后端
SamDeepThinking2 小时前
组合还是继承?我在项目里主要看这两个判断
java·后端·面试
niuju2 小时前
一种基于 Agent 的需求规范化闭环实践:让合规与规范内建于流程
后端
团团崽_七分甜2 小时前
四大数据库底层原理详解
后端
glartchen2 小时前
使用 Pixi 配置 Whisper 环境,实现采用本地大模型读取视频字幕
后端