const response = await fetch("https://mino.ai/v1/automation/run-sse", {
method: "POST",
headers: {
"X-API-Key": process.env.MINO_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
url: "https://scrapeme.live/shop/Bulbasaur/",
goal: "Extract the product name, price, and stock status",
}),
});
const reader = response.body.getReader();
const decoder = new TextDecoder();
let buffer = "";
while (true) {
const { done, value } = await reader.read();
if (done) break;
buffer += decoder.decode(value, { stream: true });
const lines = buffer.split("\n");
buffer = lines.pop() ?? "";
for (const line of lines) {
if (line.startsWith("data: ")) {
const event = JSON.parse(line.slice(6));
if (event.type === "COMPLETE" && event.status === "COMPLETED") {
console.log("Result:", event.resultJson);
}
}
}
}