Hello everyone.
I’m new to n8n, and i built my first workflow just the other day.
The workflow’s main objective is to scrape PDF files from a website, and save them in our Google Drive folders.
As input, i have a JSON file with 21 different pages to start out from. And following steps are put in a ‘loop over items’-block.
The workflow works perfectly up until page nr 13. After that, the looping stops and the workflow is terminated. I have no clue what’s causing this, as there’s no error thrown.
Anyone have experience with this? Maybe i should loop over my items in a different way?
Thanks in advance!
(here’s the code)
name "Test 123"
nodes
0
parameters
url "={{ $('Loop Over Items').item.json.url }}"
options {}
type "n8n-nodes-base.httpRequest"
typeVersion 4.2
position
0 240
1 -40
id "d55c6316-d5f0-461e-88c7-5de223dfbe46"
name "HTTP Request"
alwaysOutputData false
onError "continueRegularOutput"
1
parameters
operation "extractHtmlContent"
extractionValues
values
0
key "href"
cssSelector '.is-finished li.card__link-view a[href*="/nl/parlementair-werk/commissies/commissievergaderingen/"]'
returnValue "attribute"
attribute "href"
returnArray true
1 {}
options {}
type "n8n-nodes-base.html"
typeVersion 1.2
position
0 460
1 -40
id "22d77151-8093-4ce8-8c66-547b64a8a44d"
name "HTML"
alwaysOutputData true
onError "continueRegularOutput"
2
parameters
jsCode "const results = [];\n\nfor (const item of items) {\n const values = Object.values(item.json)[0];\n if (Array.isArray(values)) {\n for (const url of values) {\n results.push({\n json: {\n pdfUrl: url\n }\n });\n }\n }\n}\n\nreturn results;"
type "n8n-nodes-base.code"
typeVersion 2
position
0 1340
1 -40
id "3db10de3-10fe-4ece-99f4-3c099a2a84cb"
name "PDF url"
onError "continueRegularOutput"
3
parameters
url "={{ $json.pdfUrl }}"
options {}
type "n8n-nodes-base.httpRequest"
typeVersion 4.2
position
0 1780
1 -40
id "ade34351-f742-498c-9a34-483c7fcd22a1"
name "HTTP Request2"
onError "continueRegularOutput"
4
parameters
jsCode `return items.map(item => {\n const fileName = item.json.pdfUrl.split("=").pop() + ".pdf";\n\n return {\n json: {},\n binary: {\n data: {\n ...item.binary.data,\n fileName: fileName,\n mimeType: 'application/pdf'\n }\n }\n };\n});`
type "n8n-nodes-base.code"
typeVersion 2
position
0 2000
1 -40
id "df7b508a-588f-448f-95d3-d9a5ed2c62ef"
name "Code3"
onError "continueRegularOutput"
5
parameters
operation "download"
fileId
__rl true
value "1dSif9XS0nyvvId4TWCicMrgDGxvegfT-"
mode "id"
options {}
type "n8n-nodes-base.googleDrive"
typeVersion 3
position
0 -720
1 -420
id "c10ea062-487e-463e-a8ed-5facaed85217"
name "Import commissie data"
credentials
googleDriveOAuth2Api
id "LQ5mu6JaG3FDjuWY"
name "Google Drive account"
onError "continueRegularOutput"
6
parameters
options {}
type "n8n-nodes-base.splitInBatches"
typeVersion 3
position
0 -20
1 -420
id "0dc970f7-0881-42be-a6ea-442cbff738e5"
name "Loop Over Items"
onError "continueRegularOutput"
7
parameters
operation "fromJson"
options {}
type "n8n-nodes-base.extractFromFile"
typeVersion 1
position
0 -500
1 -420
id "3152d390-0de4-480a-a8f4-1c24b299f7e8"
name "Convert binary to JSON"
onError "continueRegularOutput"
8
parameters
jsCode "// Stap 1: Haal commissielijst op uit JSON\nconst commissies = $json.data || [];\n\n// Stap 2: Bereken weeknaam\nconst today = new Date();\nconst oneJan = new Date(today.getFullYear(), 0, 1);\nconst week = Math.ceil((((today - oneJan) / 86400000) + oneJan.getDay() + 1) / 7);\nconst weekName = `Week ${week} - ${today.getFullYear()}`;\n\n// Stap 3: Voeg weeknaam toe aan elk item\nreturn commissies.map(commissie => ({\n json: {\n ...commissie,\n weekFolderName: weekName\n }\n}));"
type "n8n-nodes-base.code"
typeVersion 2
position
0 -280
1 -420
id "6827b60c-ba87-44b8-85a5-eff6fa1b7417"
name "Map JSON"
onError "continueRegularOutput"
9
parameters
jsCode "const hrefs = $json.href || [];\n\nreturn hrefs.map(href => {\n return {\n json: {\n fullUrl: 'https://www.vlaamsparlement.be' + href\n }\n };\n});"
type "n8n-nodes-base.code"
typeVersion 2
position
0 680
1 -40
id "b602098f-2b0d-4c63-947d-9c735584f205"
name "Bereken fullURL"
onError "continueRegularOutput"
10
parameters
url '={{$json["fullUrl"]}}'
options {}
type "n8n-nodes-base.httpRequest"
typeVersion 4.2
position
0 900
1 -40
id "e6030f4e-f186-46f9-bae0-9644ca414ee4"
name "Data vergaderingen ophalen"
alwaysOutputData true
onError "continueRegularOutput"
11
parameters
operation "extractHtmlContent"
extractionValues
values
0
cssSelector 'div a[href^="https://docs.vlaamsparlement.be/files/"]'
returnValue "attribute"
attribute "href"
returnArray true
options {}
type "n8n-nodes-base.html"
typeVersion 1.2
position
0 1120
1 -40
id "b14819cc-bd9e-4095-a7ef-98adce2be0d6"
name "Extract samenvatting URL"
onError "continueRegularOutput"
12
parameters
jsCode 'const folderId = $items("folderID")[0].json.folderId;\nconst pdfItems = $items("PDF url");\n\nreturn pdfItems.map(item => {\n return {\n json: {\n pdfUrl: item.json.pdfUrl,\n folderId: folderId\n }\n };\n});'
type "n8n-nodes-base.code"
typeVersion 2
position
0 1560
1 -40
id "7e2a1bfc-d6b1-4586-b662-0b2c06d18395"
name "Toevoegen folder ID"
onError "continueRegularOutput"
13
parameters
assignments
assignments
0
id "a2da3d59-07cf-4e24-9d7a-edf33cfdaab6"
name "folderId"
value "={{ $json.id }}"
type "string"
options {}
type "n8n-nodes-base.set"
typeVersion 3.4
position
0 460
1 -280
id "666cc90d-610b-4f99-9017-9972af092178"
name "folderID"
onError "continueRegularOutput"
14
parameters
driveId
__rl true
mode "list"
value "My Drive"
folderId
__rl true
value "={{ $('Toevoegen folder ID').item.json.folderId }}"
mode "id"
options {}
type "n8n-nodes-base.googleDrive"
typeVersion 3
position
0 2220
1 -40
id "bcfbf0e3-7eeb-490a-9b03-9b857c0c8675"
name "Upload PDf"
credentials
googleDriveOAuth2Api
id "LQ5mu6JaG3FDjuWY"
name "Google Drive account"
onError "continueRegularOutput"
15
parameters
resource "folder"
name "={{ $('Loop Over Items').item.json.weekFolderName }}"
driveId
__rl true
mode "list"
value "My Drive"
folderId
__rl true
value "={{ $('Loop Over Items').item.json.mapId }}"
mode "id"
options {}
type "n8n-nodes-base.googleDrive"
typeVersion 3
position
0 240
1 -280
id "507ac14f-f09f-4b43-a280-88f8c73a5872"
name "Google Drive"
credentials
googleDriveOAuth2Api
id "LQ5mu6JaG3FDjuWY"
name "Google Drive account"
onError "continueRegularOutput"
16
parameters
rule
interval
0
field "weeks"
triggerAtDay
0 5
triggerAtHour 20
type "n8n-nodes-base.scheduleTrigger"
typeVersion 1.2
position
0 -940
1 -420
id "8211379a-4f07-48cf-95be-19b69a5ae77d"
name "Schedule Trigger"
pinData {}
connections
HTTP Request
main
0
0
node "HTML"
type "main"
index 0
HTML
main
0
0
node "Bereken fullURL"
type "main"
index 0
PDF url
main
0
0
node "Toevoegen folder ID"
type "main"
index 0
HTTP Request2
main
0
0
node "Code3"
type "main"
index 0
Code3
main
0
0
node "Upload PDf"
type "main"
index 0
Import commissie data
main
0
0
node "Convert binary to JSON"
type "main"
index 0
Loop Over Items
main
0 []
1
0
node "Google Drive"
type "main"
index 0
Convert binary to JSON
main
0
0
node "Map JSON"
type "main"
index 0
Map JSON
main
0
0
node "Loop Over Items"
type "main"
index 0
Bereken fullURL
main
0
0
node "Data vergaderingen ophalen"
type "main"
index 0
Data vergaderingen ophalen
main
0
0
node "Extract samenvatting URL"
type "main"
index 0
Extract samenvatting URL
main
0
0
node "PDF url"
type "main"
index 0
Toevoegen folder ID
main
0
0
node "HTTP Request2"
type "main"
index 0
folderID
main
0
0
node "HTTP Request"
type "main"
index 0
Upload PDf
main
0
0
node "Loop Over Items"
type "main"
index 0
Google Drive
main
0
0
node "folderID"
type "main"
index 0
Schedule Trigger
main
0
0
node "Import commissie data"
type "main"
index 0
active true
settings
executionOrder "v1"
versionId "96852292-78f3-4abe-bc58-727d6dffb160"
meta
templateCredsSetupCompleted true
instanceId "3c3b83cb2ce9316e96d1b4fead73de385b1bb5c502784e30284080b07a4756fa"
id "Q3tlZBtFC0OpsHz2"
tags []