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())
相关推荐
程序员海军4 小时前
用了两年多 GPT,我最近开始换模型了,还折腾了个求职避坑 Agent
前端·人工智能·后端
码士集团小青4 小时前
SpringBoot 集成缓存性能之王 Caffeine
spring boot·后端·缓存
excel6 小时前
IndexNow:让搜索引擎更快发现网站更新的主动通知协议
前端·后端·架构
Json____6 小时前
用 FastAPI + Vue3 打造一套完整的在线考试系统:从组卷到阅卷的业务闭环实践
后端·node.js·fastapi·it学习·wwwoop.com
小灰灰搞电子7 小时前
Rust+Slint 实现FTP客户端调试助手源码分享
开发语言·后端·rust
专业程序开发源8 小时前
springboot欧缇蔓月子中心管理系统82697-计算机课程设计、毕业设计
java·spring boot·后端·python·spring·django·课程设计
卷无止境8 小时前
面向arm64桌面客户端开发全景:语言、框架与生态
后端·python
IT_陈寒9 小时前
JavaScript的闭包陷阱,这个坑我躺了三天才爬出来
前端·人工智能·后端
用户8356290780519 小时前
如何使用 Python 对 Excel 数据进行分组和分级显示
后端·python
vx_Biye_Design9 小时前
django房屋租赁推荐系统78455-计算机课程设计、毕业设计
vue.js·spring boot·后端·python·django·课程设计·express