This is the official developer community of Apify and Crawlee.
userDatauserData to the category handler. However, since a URL is only scraped once, only the first category gets saved and all others discarded.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
});<html><head></head><body></body></html><html><head></head><body></body></html>await waitForSelector('#myID')await waitForSelector('#myID')
1

addRequestsBatchedaddRequestsBatched (& also addRequestsaddRequests) It works perfectly fine when I run it locally, but it on Apify it does not seem to do anything. Has anyone faced this issue or knows what might be causing it?writeStreamwriteStream to save files into key-value-store? await <kvs>.setValue('<file-key-here>,<Buffer>,<content-type>) await <kvs>.setValue('<file-key-here>,<Buffer>,<content-type>) ;JSON.stringify()JSON.stringify() returned undefinedlet 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
}