This is the official developer community of Apify and Crawlee.

1

userDatauserData<html><head></head><body></body></html><html><head></head><body></body></html>await waitForSelector('#myID')await waitForSelector('#myID')addRequestsBatchedaddRequestsBatchedaddRequestsaddRequestswriteStreamwriteStreamawait <kvs>.setValue('<file-key-here>,<Buffer>,<content-type>) await <kvs>.setValue('<file-key-here>,<Buffer>,<content-type>) JSON.stringify()JSON.stringify()let data = JSON.stringify(body)
if(data){
await setValue(<key>, body , content-type.type
}let data = JSON.stringify(body)
if(data){
await setValue(<key>, body , content-type.type
}import { Router } from "crawlee";
export const router = Router.create();
// ... other handlers
// imagine the category handler is called twice
router.addHandler("CATEGORY", async ({ enqueueLinks }) => {
// ... parsing
// result of first call
await enqueueLinks({
urls: ["https://example.com/my-product"],
userData: { category: "foo" },
label: "DETAIL",
});
// result of second call
await enqueueLinks({
urls: ["https://example.com/my-product"],
userData: { category: "bar" },
label: "DETAIL",
});
});
router.addHandler("DETAIL", async ({ request }) => {
// todo: how to get both "foo" and "bar" here?
const category = request.userData.category;
// ... saving
});import { Router } from "crawlee";
export const router = Router.create();
// ... other handlers
// imagine the category handler is called twice
router.addHandler("CATEGORY", async ({ enqueueLinks }) => {
// ... parsing
// result of first call
await enqueueLinks({
urls: ["https://example.com/my-product"],
userData: { category: "foo" },
label: "DETAIL",
});
// result of second call
await enqueueLinks({
urls: ["https://example.com/my-product"],
userData: { category: "bar" },
label: "DETAIL",
});
});
router.addHandler("DETAIL", async ({ request }) => {
// todo: how to get both "foo" and "bar" here?
const category = request.userData.category;
// ... saving
});