Tìm và thay thế
Thay thế mọi kết quả khớp chính xác bằng văn bản bạn chọn.
URL cơ sở: https://happytails.ai · API công khai chưa được kết nối
Xử lý
Thay thế theo đúng ký tự và phân biệt chữ hoa, chữ thường. Dùng công cụ Kiểm tra biểu thức chính quy nếu cần dùng biểu thức chính quy.
Khi bạn gửi yêu cầu API, dữ liệu đầu vào được xử lý trên máy chủ.
Tham số yêu cầu
Gửi một đối tượng JSON. Các thuộc tính không xác định sẽ bị từ chối. Những tùy chọn bị bỏ qua sẽ dùng giá trị mặc định bên dưới. Nhập số và giá trị boolean dưới dạng giá trị JSON không có dấu ngoặc kép.
input là chuỗi mặc định để trống, dài tối đa 1.000.000 ký tự. Hãy thay đổi dữ liệu đầu vào hoặc cài đặt để cập nhật kết quả. Kết quả cũng thay đổi ngay khi bạn nhập.
Điểm cuối này không chấp nhận mảng files.
Tùy chọn
options.findstringTìm
options.replacestringThay bằng
Phản hồi khi thành công
Phản hồi HTTP 200 chứa tool và result. Văn bản nằm trong result.text. Dữ liệu JSON đã phân tích cú pháp cũng có thể xuất hiện trong result.data. Các tệp được tạo nằm trong result.files, với name, mime, bytes và base64. Hãy giải mã các byte trước khi lưu. Mảng tệp rỗng và văn bản có giá trị null đều hợp lệ khi thao tác trả về loại kết quả khác.
Lược đồ đầu ra đầy đủ
{
"type": "object",
"required": [
"tool",
"result"
],
"properties": {
"tool": {
"type": "string"
},
"result": {
"type": "object",
"required": [
"text",
"files"
],
"properties": {
"text": {
"type": [
"string",
"null"
]
},
"data": {
"description": "Parsed JSON when the textual result is JSON."
},
"name": {
"type": "string"
},
"mime": {
"type": "string"
},
"files": {
"type": "array",
"items": {
"type": "object",
"required": [
"name",
"mime",
"bytes",
"base64"
],
"properties": {
"name": {
"type": "string"
},
"mime": {
"type": "string"
},
"bytes": {
"type": "integer"
},
"base64": {
"type": "string",
"contentEncoding": "base64"
}
}
}
}
}
}
}
}Giới hạn và lỗi
Điểm cuối này áp dụng các giới hạn bên dưới. Các giới hạn bổ sung về định dạng, số trang, thời lượng và mô hình trong phần ghi chú hoạt động cũng được áp dụng. Giới hạn của giao diện trình duyệt có thể khác với giới hạn của API.
request_bytes- 8388608
input_characters- 1000000
files_bytes- 5242880
max_files- 0
timeout_seconds- 12
Yêu cầu không hợp lệ trả về đối tượng error có các trường code và message. Xem Mã trạng thái HTTP, thử lại, thời gian chờ và yêu cầu đồng thời. Quá trình xử lý diễn ra đồng bộ và kết quả được trả về trong cùng phản hồi.
Lược đồ yêu cầu đầy đủ
Mở rộng lược đồ JSON
{
"type": "object",
"additionalProperties": false,
"properties": {
"input": {
"type": "string",
"maxLength": 1000000,
"default": "",
"description": "Plain text input. File tools use files instead unless otherwise documented."
},
"options": {
"type": "object",
"additionalProperties": false,
"properties": {
"find": {
"type": "string",
"description": "Find",
"default": ""
},
"replace": {
"type": "string",
"description": "Replace with",
"default": ""
}
}
}
}
}Để tự động hóa trình duyệt, hãy dùng tài nguyên trung tâm Hướng dẫn WebMCP để tìm những công cụ mà trình duyệt thực sự cung cấp.
curl https://happytails.ai/api/v1/tools/find-and-replace/run \
-H "Content-Type: application/json" \
--data '{"input": "Hello world", "options": {"find": "world", "replace": "Ada"}}'const payload = {
"input": "Hello world",
"options": {
"find": "world",
"replace": "Ada"
}
};
const response = await fetch(
"https://happytails.ai/api/v1/tools/find-and-replace/run",
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload)
}
);
const data = await response.json();
if (!response.ok) throw new Error(data.error.message);
console.log(data.result);import json
from urllib.request import Request, urlopen
payload = json.loads('{"input": "Hello world", "options": {"find": "world", "replace": "Ada"}}')
request = Request(
"https://happytails.ai/api/v1/tools/find-and-replace/run",
data=json.dumps(payload).encode(),
headers={"Content-Type": "application/json"},
)
with urlopen(request, timeout=200) as response:
result = json.load(response)
print(result){
"input": "Hello world",
"options": {
"find": "world",
"replace": "Ada"
}
}Thay địa chỉ gốc của API và các giá trị đầu vào bằng các giá trị phù hợp với ứng dụng của bạn.
{
"tool": "find-and-replace",
"result": {
"text": "Hello Ada",
"files": [],
"name": "result.txt",
"mime": "text/plain;charset=utf-8"
}
}{
"error": {
"code": "INVALID_INPUT",
"message": "Unknown request property. See the tool input schema."
}
}