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())
相关推荐
脚本自动化开发15 分钟前
柔光屏平板怎么选?华为 MatePad Air Z 柔光版学
后端
程序猿DD1 小时前
OctaFuse 2.19.0:重做管理后台界面与交互,模型目录同步更新
后端
金銀銅鐵2 小时前
带您看懂字节码指令(一):一帧里有什么
java·后端·ai编程
码事漫谈3 小时前
Agent 测评是什么?大白话讲一讲
后端
皮皮林5514 小时前
在 IDEA 里斗个地主不过分吧!
后端
SomeOtherTime4 小时前
Rust所有权(AI回答)
开发语言·后端·rust
程序员cxuan5 小时前
离谱,AI 大佬顺手搓了个 YouTube ,而我顺手给他搓了个中文插件
人工智能·后端·程序员
学长毕设5 小时前
基于springboot科创竞赛信息平台-附源码
java·spring boot·后端
深蓝AI6 小时前
Gemini Decisions API 来了:一次前向打分取代逐字解码,校准误差 0.0250 才是 agent 分支调用的真门槛
人工智能·后端
学长毕设6 小时前
基于SpringBoot公务员考试交流平台-附源码
java·spring boot·后端