Only One Result Returned When Scraping – Help Needed pls
Hi, I’m having an issue with the scrap badges. No matter what I do, it always returns only one result instead of multiple results. I want to understand why this happens.
( n8n node javascrpit)
Here’s a simplified version of my current code:
return [
{
json: {
body: {
urls: $input.first().json.links,
formats: [
{
type: "json",
prompt: "Extract from each page: address (.lc-location), price in COP (digits only, .main-price), property type (h2.lc-title), transaction type (h2.lc-title), and absolute URL (a.lc-data href)",
schema: {
type: "object",
properties: {
url: { type: "string" },
address: { type: "string" },
priceCOP: { type: "integer" },
property_type: { type: "string" },
transaction_type: { type: "string" }
},
required: ["url", "address", "priceCOP", "property_type", "transaction_type"]
}
}
],
maxConcurrency: 1,
onlyMainContent: true,
includeTags: ["h2.lc-title", "strong", "p.main-price", "a.lc-data"],
maxAge: 10,
removeBase64Images: true,
waitFor: 10000
}
}
}
];
Could you please help me understand why it always returns only one result and how I can get all the results?
4 Replies
Hey! If you want to get back more results, you're going to want to make sure you specify an array of JSON objects instead of just a JSON object. Otherwise, you will only get exactly one object back each time.
Had this same issue the other day, thank you for the email response @micah.stairs
Thank you very much. I have one more question. I noticed that my response is now using about 5 credits. Why is that? Does the scrape consume 5 credits by default? Could you please clarify that doubt for me?
By the way, I’m only sending one URL, and when I send two URLs, it consumes 10 credits.
"statusCode":
200,
"contentType":
"text/html; charset=utf-8",
"proxyUsed":
"basic",
"creditsUsed":
5
Hi @jHOkE if you're using scrape with JSON format, then it will consume 5 credits per page.