feat: update kijiji scraper
Signed-off-by: Dmytro Stanchiev <git@dmytros.dev>
This commit is contained in:
18
src/index.ts
18
src/index.ts
@@ -26,8 +26,12 @@ const server = Bun.serve({
|
||||
{ status: 400 },
|
||||
);
|
||||
|
||||
const items = await fetchKijijiItems(SEARCH_QUERY, 5);
|
||||
if (!items)
|
||||
const items = await fetchKijijiItems(SEARCH_QUERY, 1, undefined, {}, {
|
||||
includeImages: true,
|
||||
sellerDataDepth: 'detailed',
|
||||
includeClientSideData: false,
|
||||
});
|
||||
if (!items || items.length === 0)
|
||||
return Response.json(
|
||||
{ message: "Search didn't return any results!" },
|
||||
{ status: 404 },
|
||||
@@ -85,11 +89,13 @@ const server = Bun.serve({
|
||||
);
|
||||
|
||||
// Parse optional parameters with defaults
|
||||
const minPrice = reqUrl.searchParams.get("minPrice")
|
||||
? parseInt(reqUrl.searchParams.get("minPrice")!)
|
||||
const minPriceParam = reqUrl.searchParams.get("minPrice");
|
||||
const minPrice = minPriceParam
|
||||
? Number.parseInt(minPriceParam, 10)
|
||||
: undefined;
|
||||
const maxPrice = reqUrl.searchParams.get("maxPrice")
|
||||
? parseInt(reqUrl.searchParams.get("maxPrice")!)
|
||||
const maxPriceParam = reqUrl.searchParams.get("maxPrice");
|
||||
const maxPrice = maxPriceParam
|
||||
? Number.parseInt(maxPriceParam, 10)
|
||||
: undefined;
|
||||
const strictMode = reqUrl.searchParams.get("strictMode") === "true";
|
||||
const exclusionsParam = reqUrl.searchParams.get("exclusions");
|
||||
|
||||
Reference in New Issue
Block a user