抓取两个参数
- 随便用ai聊一句
python
import requests
# 定义函数来设置Cookie
def set_cookie(headers, cookie_value,x_csrf_token):
headers['Cookie'] = cookie_value
headers['x-csrf-token'] = x_csrf_token
url = 'https://www.yuque.com/api/ai/ai_writing/completion'
headers = {
'Content-Type': 'application/json',
}
# 设置Cookie
cookie_value = ''
x_csrf_token = ''
set_cookie(headers, cookie_value)
data = {
"content": "介绍自己",
"type": "custom",
"stream": False,
"http": True,
}
response = requests.post(url, headers=headers, json=data)
print(response.text)
java
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
public class YuqueApiRequest {
public static void main(String[] args) {
String url = "https://www.yuque.com/api/ai/ai_writing/completion";
JSONObject data = JSONUtil.createObj()
.putOnce("content", "介绍自己")
.putOnce("type", "custom")
.putOnce("stream", false)
.putOnce("http", true);
String response = HttpRequest.post(url)
.header("Content-Type", "application/json")
.header("Cookie", "")
.header("x-csrf-token", "")
.body(data.toString())
.execute()
.body();
System.out.println(response);
}
}
真的好水水水水啊 正好是饭点,给佬友们下饭