-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Expand file tree
/
Copy pathUltimate Scraper Workflow for n8n.json
More file actions
1971 lines (1971 loc) · 40.1 KB
/
Copy pathUltimate Scraper Workflow for n8n.json
File metadata and controls
1971 lines (1971 loc) · 40.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
"id": "kZ3aL4r7xc96Q7lp",
"meta": {
"instanceId": "b8b2c0d20b02864cf66adc9cbefc86e9e56de0252b653d37ba6613341b5e0bef",
"templateCredsSetupCompleted": true
},
"name": "Selenium Ultimate Scraper Workflow",
"tags": [],
"nodes": [
{
"id": "20d35d68-db49-4183-a913-85ad06c13912",
"name": "Extract First Url Match",
"type": "n8n-nodes-base.html",
"position": [
1820,
540
],
"parameters": {
"options": {},
"operation": "extractHtmlContent",
"extractionValues": {
"values": [
{
"key": "Url Find ",
"attribute": "href",
"cssSelector": "=a[href*=\"https://\"][href*=\"{{ $('Edit Fields (For testing prupose )').item.json['Website Domaine'] }}\"]\n",
"returnArray": true,
"returnValue": "attribute"
}
]
}
},
"typeVersion": 1.2
},
{
"id": "9167ea20-fc9c-4d75-bf4d-bb2016079dd0",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
2060,
700
],
"parameters": {
"model": "gpt-4o",
"options": {}
},
"credentials": {
"openAiApi": {
"id": "FmszNHDDVS32ud21",
"name": "OpenAi account"
}
},
"typeVersion": 1
},
{
"id": "42a8646d-1b0b-4309-a87d-9c8aeb355a28",
"name": "Clean Webdriver ",
"type": "n8n-nodes-base.httpRequest",
"notes": "Script to delete traces of selenium in the browser ",
"position": [
3120,
560
],
"parameters": {
"url": "=http://selenium_chrome:4444/wd/hub/session/{{ $('Create Selenium Session').item.json.value.sessionId }}/execute/sync",
"method": "POST",
"options": {},
"jsonBody": "{\n \"script\": \"Object.defineProperty(navigator, 'webdriver', { get: () => undefined }); window.navigator.chrome = { runtime: {} }; Object.defineProperty(navigator, 'languages', { get: () => ['en-US', 'en'] }); Object.defineProperty(navigator, 'plugins', { get: () => [1, 2, 3, 4, 5] });\",\n \"args\": []\n}\n",
"sendBody": true,
"specifyBody": "json"
},
"notesInFlow": false,
"typeVersion": 4.2
},
{
"id": "107dd8de-e341-4819-a493-94ed57fd0f33",
"name": "Delete Session",
"type": "n8n-nodes-base.httpRequest",
"position": [
5180,
920
],
"parameters": {
"url": "=http://selenium_chrome:4444/wd/hub/session/{{ $('Create Selenium Session').item.json.value.sessionId }}",
"method": "DELETE",
"options": {}
},
"typeVersion": 4.2
},
{
"id": "8c7ec6bc-d417-48c2-a6f2-ecce27803671",
"name": "Delete Session2",
"type": "n8n-nodes-base.httpRequest",
"position": [
6740,
-160
],
"parameters": {
"url": "=http://selenium_chrome:4444/wd/hub/session/{{ $('Create Selenium Session').item.json.value.sessionId }}",
"method": "DELETE",
"options": {}
},
"typeVersion": 4.2
},
{
"id": "e43ecd94-b7f2-4f73-a9fa-b829de9e0296",
"name": "If Block1",
"type": "n8n-nodes-base.if",
"position": [
6520,
-20
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "e6e6e15d-1cfe-48be-8ea0-f112e9781c9d",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.content }}",
"rightValue": "BLOCK"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "08e46f63-41b5-4606-8f2c-df9e96c9c34e",
"name": "Delete Session3",
"type": "n8n-nodes-base.httpRequest",
"position": [
6740,
60
],
"parameters": {
"url": "=http://selenium_chrome:4444/wd/hub/session/{{ $('Create Selenium Session').item.json.value.sessionId }}",
"method": "DELETE",
"options": {}
},
"typeVersion": 4.2
},
{
"id": "b47d9b22-9a59-4c7a-8cba-9487f18207ee",
"name": "Limit",
"type": "n8n-nodes-base.limit",
"position": [
5120,
-100
],
"parameters": {},
"typeVersion": 1
},
{
"id": "541622f7-562b-4e8a-93e5-61e6e918ff52",
"name": "Delete Session1",
"type": "n8n-nodes-base.httpRequest",
"position": [
5180,
720
],
"parameters": {
"url": "=http://selenium_chrome:4444/wd/hub/session/{{ $('Create Selenium Session').item.json.value.sessionId }}",
"method": "DELETE",
"options": {}
},
"typeVersion": 4.2
},
{
"id": "825be0d7-9dd3-4a2f-8c3d-fd405f59a5d6",
"name": "Delete Session4",
"type": "n8n-nodes-base.httpRequest",
"onError": "continueRegularOutput",
"position": [
5780,
260
],
"parameters": {
"url": "=http://selenium_chrome:4444/wd/hub/session/{{ $('Create Selenium Session').item.json.value.sessionId }}",
"method": "DELETE",
"options": {}
},
"retryOnFail": false,
"typeVersion": 4.2
},
{
"id": "56f6f4f6-f737-4de8-bdfe-029546909677",
"name": "Success with cookie",
"type": "n8n-nodes-base.respondToWebhook",
"position": [
7260,
60
],
"parameters": {
"options": {
"responseCode": 200
}
},
"typeVersion": 1.1
},
{
"id": "c6939773-e230-45e1-bf76-d0299c2c7066",
"name": "Respond to Webhook2",
"type": "n8n-nodes-base.respondToWebhook",
"position": [
6920,
-160
],
"parameters": {
"options": {
"responseCode": 200
},
"respondWith": "json",
"responseBody": "{\n \"Success \": \"Request has been block by the targeted website\"\n}"
},
"typeVersion": 1.1
},
{
"id": "ea921f11-323f-4c79-8cc6-779b39498b05",
"name": "Code",
"type": "n8n-nodes-base.code",
"position": [
4700,
-100
],
"parameters": {
"jsCode": "// Récupère les données du nœud Webhook (en remplaçant \"Webhook\" par le nom du nœud Webhook dans votre workflow)\nconst webhookData = $node[\"Webhook\"].json;\n\n// Fonction pour convertir la valeur de sameSite\nfunction convertSameSite(value) {\n // Conversion spécifique des valeurs de sameSite\n const conversionMap = {\n \"unspecified\": \"None\",\n \"lax\": \"Lax\",\n \"strict\": \"Strict\"\n };\n \n // Si la valeur existe dans le tableau de conversion, on la convertit\n if (value in conversionMap) {\n return conversionMap[value];\n }\n \n // Si la valeur est déjà une des valeurs acceptées par Selenium\n const allowedValues = [\"Strict\", \"Lax\", \"None\"];\n if (allowedValues.includes(value)) {\n return value;\n } else {\n // Si la valeur n'est pas reconnue, on la remplace par \"Lax\" (par défaut)\n return \"Lax\";\n }\n}\n\n// Vérifiez et traitez les données des cookies\nif (webhookData.body && webhookData.body.cookies) {\n let items = [];\n for (const cookieObject of webhookData.body.cookies) {\n if (cookieObject.cookie) {\n // Convertir la valeur de sameSite\n cookieObject.cookie.sameSite = convertSameSite(cookieObject.cookie.sameSite);\n \n // Ajouter le cookie à la liste des items\n items.push({\n json: cookieObject.cookie\n });\n }\n }\n return items;\n}\n\n// Si les cookies ne sont pas trouvés, renvoyer un tableau vide\nreturn [];\n"
},
"typeVersion": 2
},
{
"id": "c3d77928-eefc-4903-9b4f-b14bd6f34e3c",
"name": "Delete Session5",
"type": "n8n-nodes-base.httpRequest",
"onError": "continueRegularOutput",
"position": [
3940,
360
],
"parameters": {
"url": "=http://selenium_chrome:4444/wd/hub/session/{{ $('Create Selenium Session').item.json.value.sessionId }}",
"method": "DELETE",
"options": {}
},
"retryOnFail": false,
"typeVersion": 4.2
},
{
"id": "036cfce6-8082-4539-bb0e-980368679fe5",
"name": "Error",
"type": "n8n-nodes-base.respondToWebhook",
"position": [
4120,
360
],
"parameters": {
"options": {
"responseCode": 404
},
"respondWith": "json",
"responseBody": "{\n \"Error\": \"Cookies are note for the targeted url\"\n}"
},
"typeVersion": 1.1
},
{
"id": "09d6a99b-d8b3-40c9-b74a-14014e3647e2",
"name": "Error1",
"type": "n8n-nodes-base.respondToWebhook",
"position": [
6000,
260
],
"parameters": {
"options": {
"responseCode": 500
}
},
"typeVersion": 1.1
},
{
"id": "0b1f3442-6b70-405f-b597-642e9c982b82",
"name": "Error2",
"type": "n8n-nodes-base.respondToWebhook",
"position": [
3060,
780
],
"parameters": {
"options": {
"responseCode": 500
}
},
"typeVersion": 1.1
},
{
"id": "4d0112bb-cbfd-45c6-961a-964bd8f59cac",
"name": "If",
"type": "n8n-nodes-base.if",
"position": [
3760,
200
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "1bffbc80-9913-46e7-a594-ebc26948c83b",
"operator": {
"type": "string",
"operation": "contains"
},
"leftValue": "={{ $('Webhook').item.json.body.cookies[0].cookie.domain }}",
"rightValue": "={{ $('Webhook').item.json.body.Url }}"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "58a50b80-df4c-4b6f-a682-72237f4dbdef",
"name": "Inject Cookie",
"type": "n8n-nodes-base.httpRequest",
"onError": "continueRegularOutput",
"position": [
4900,
-100
],
"parameters": {
"url": "=http://selenium_chrome:4444/wd/hub/session/{{ $('Create Selenium Session').item.json.value.sessionId }}/cookie",
"method": "POST",
"options": {},
"jsonBody": "={\n \"cookie\": {\n \"name\": \"{{ $json.name }}\",\n \"value\": \"{{ $json.value }}\",\n \"domain\": \"{{ $json.domain }}\",\n \"path\": \"{{ $json.path }}\",\n \"secure\": {{ $json.secure }},\n \"httpOnly\": {{ $json.httpOnly }},\n \"sameSite\": \"{{ $json.sameSite }}\",\n \"expirationDate\": {{ $json.expirationDate }}\n }\n}",
"sendBody": true,
"specifyBody": "json"
},
"typeVersion": 4.2
},
{
"id": "39f7401b-b6b7-4f0c-9afc-8f144d394350",
"name": "Respond to Webhook3",
"type": "n8n-nodes-base.respondToWebhook",
"position": [
5400,
720
],
"parameters": {
"options": {
"responseCode": 200
},
"respondWith": "json",
"responseBody": "{\n \"Success \": \"Request has been block by the targeted website\"\n}"
},
"typeVersion": 1.1
},
{
"id": "80b107cc-2f6c-46f0-a597-e85594634492",
"name": "Success",
"type": "n8n-nodes-base.respondToWebhook",
"position": [
5740,
920
],
"parameters": {
"options": {
"responseKey": "={{ $json.output }}",
"responseCode": 200
}
},
"typeVersion": 1.1
},
{
"id": "94a97354-07d9-428e-989c-ef066f9b4d8a",
"name": "Go on url",
"type": "n8n-nodes-base.httpRequest",
"onError": "continueErrorOutput",
"position": [
3900,
780
],
"parameters": {
"url": "=http://selenium_chrome:4444/wd/hub/session/{{ $('Create Selenium Session').item.json.value.sessionId }}/url",
"method": "POST",
"options": {},
"jsonBody": "={\n \"url\": \"{{ $('Webhook').item.json.body['Target Url'] }}\"\n}\n",
"sendBody": true,
"specifyBody": "json"
},
"retryOnFail": true,
"typeVersion": 4.2
},
{
"id": "fd044cf3-594d-48af-bbd1-f2d9adedcbc1",
"name": "Delete Session6",
"type": "n8n-nodes-base.httpRequest",
"onError": "continueRegularOutput",
"position": [
4360,
1200
],
"parameters": {
"url": "=http://selenium_chrome:4444/wd/hub/session/{{ $('Create Selenium Session').item.json.value.sessionId }}",
"method": "DELETE",
"options": {}
},
"retryOnFail": false,
"typeVersion": 4.2
},
{
"id": "7c28c3b6-1141-4609-8774-cb6b4d842b97",
"name": "Error3",
"type": "n8n-nodes-base.respondToWebhook",
"position": [
4520,
1200
],
"parameters": {
"options": {
"responseCode": 500
},
"respondWith": "json",
"responseBody": "{\n \"Error\": \"Page crash on the extracted url\"\n}"
},
"typeVersion": 1.1
},
{
"id": "52f78923-156f-4861-88ba-f0253c483bd9",
"name": "Information Extractor",
"type": "@n8n/n8n-nodes-langchain.informationExtractor",
"position": [
2040,
540
],
"parameters": {
"text": "={{ $json['Url Find '][1] }}{{ $json['Url Find '][2] }}{{ $json['Url Find '][3] }}",
"options": {
"systemPromptTemplate": "=You are an expert extraction algorithm.\nOnly extract relevant url from the unstructured urls array.\nA relevant url is a url whre you can find relevant information about this subject : {{ $('Edit Fields (For testing prupose )').item.json.Subject }}, on this domaine name : {{ $('Edit Fields (For testing prupose )').item.json['Website Domaine'] }}.\nIf you do not know the value of an attribute asked to extract, you need \\ attribute's value as NA."
},
"attributes": {
"attributes": [
{
"name": "Good_url_for_etract_information",
"required": true,
"description": "=The url where I can extract relevant infroamtion on this subject : {{ $('Edit Fields (For testing prupose )').item.json.Subject }} on this domaine name : {{ $('Edit Fields (For testing prupose )').item.json['Website Domaine'] }}"
}
]
}
},
"typeVersion": 1
},
{
"id": "6ac249e2-a9d8-4590-b050-3a0a2472fa3c",
"name": "Check if empty of NA",
"type": "n8n-nodes-base.if",
"position": [
2440,
540
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "or",
"conditions": [
{
"id": "9470fb6c-e367-4af7-a697-275e724fe771",
"operator": {
"type": "string",
"operation": "empty",
"singleValue": true
},
"leftValue": "={{ $json.output.Good_url_for_etract_information }}",
"rightValue": ""
},
{
"id": "8518e9a9-5b0c-4699-97c5-d9b7b1943918",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.output.Good_url_for_etract_information }}",
"rightValue": "NA"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "f380eff7-3d18-4791-9dac-8a88d3fdcc4f",
"name": "If Block",
"type": "n8n-nodes-base.if",
"position": [
4960,
840
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "e6e6e15d-1cfe-48be-8ea0-f112e9781c9d",
"operator": {
"type": "string",
"operation": "contains"
},
"leftValue": "={{ $json.content }}",
"rightValue": "BLOCK"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "43382397-89b5-4b90-9016-49109ec04baf",
"name": "Google search Query ",
"type": "n8n-nodes-base.httpRequest",
"position": [
1600,
540
],
"parameters": {
"url": "=https://www.google.com/search?q=site:{{ $json['Website Domaine'] }}+{{$json.Subject}}&oq=site&gs_lcrp=EgZjaHJvbWUqCAgAEEUYJxg7MggIABBFGCcYOzIICAEQRRgnGDsyBggCEEUYOzIRCAMQRRg5GEMYyQMYgAQYigUyBggEEEUYQDIGCAUQRRg9MgYIBhBFGD0yBggHEEUYPdIBCDEwNTRqMGo3qAIAsAIA&sourceid=chrome&ie=UTF-8",
"options": {}
},
"typeVersion": 4.2
},
{
"id": "d34256af-1b43-4f64-853c-cf063b8c6b68",
"name": "Create Selenium Session",
"type": "n8n-nodes-base.httpRequest",
"onError": "continueErrorOutput",
"position": [
2680,
640
],
"parameters": {
"url": "http://selenium_chrome:4444/wd/hub/session",
"method": "POST",
"options": {
"timeout": 5000
},
"jsonBody": "{\n \"capabilities\": {\n \"alwaysMatch\": {\n \"browserName\": \"chrome\",\n \"goog:chromeOptions\": {\n \"args\": [ \n \"--disable-blink-features=AutomationControlled\",\n \"--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3\"\n ]\n }\n }\n }\n}\n",
"sendBody": true,
"specifyBody": "json"
},
"retryOnFail": true,
"typeVersion": 4.2
},
{
"id": "4f0f696c-9637-4c7d-82ae-1f5c36bb9cd1",
"name": "Get ScreenShot 1",
"type": "n8n-nodes-base.httpRequest",
"onError": "continueErrorOutput",
"position": [
4420,
840
],
"parameters": {
"url": "=http://selenium_chrome:4444/wd/hub/session/{{ $('Create Selenium Session').item.json.value.sessionId }}/screenshot",
"options": {}
},
"typeVersion": 4.2
},
{
"id": "ba72c0cf-217a-4411-80f6-ca28ccdb0151",
"name": "Refresh browser",
"type": "n8n-nodes-base.httpRequest",
"onError": "continueErrorOutput",
"position": [
5320,
-100
],
"parameters": {
"url": "=http:///selenium_chrome:4444/wd/hub/session/{{ $('Create Selenium Session').item.json.value.sessionId }}/refresh",
"method": "POST",
"options": {},
"jsonBody": "{}",
"sendBody": true,
"specifyBody": "json"
},
"typeVersion": 4.2
},
{
"id": "b6ba7068-399a-467d-ba58-7f47d650e2f1",
"name": "Get ScreenShot ",
"type": "n8n-nodes-base.httpRequest",
"onError": "continueErrorOutput",
"position": [
5880,
-20
],
"parameters": {
"url": "=http://selenium_chrome:4444/wd/hub/session/{{ $('Create Selenium Session').item.json.value.sessionId }}/screenshot",
"options": {}
},
"typeVersion": 4.2
},
{
"id": "792649be-0ee2-442f-bc21-d0c297cea227",
"name": "Convert to File",
"type": "n8n-nodes-base.convertToFile",
"onError": "continueErrorOutput",
"position": [
6160,
-20
],
"parameters": {
"options": {},
"operation": "toBinary",
"sourceProperty": "value"
},
"typeVersion": 1.1
},
{
"id": "49e58759-bedf-4f38-a96c-bd18e67b8aaf",
"name": "Convert to File1",
"type": "n8n-nodes-base.convertToFile",
"onError": "continueErrorOutput",
"position": [
4600,
840
],
"parameters": {
"options": {},
"operation": "toBinary",
"sourceProperty": "value"
},
"typeVersion": 1.1
},
{
"id": "3735f5f5-665e-4649-b1c2-84a4a8699f70",
"name": "Delete Session7",
"type": "n8n-nodes-base.httpRequest",
"onError": "continueRegularOutput",
"position": [
2920,
780
],
"parameters": {
"url": "=http://selenium_chrome:4444/wd/hub/session/{{ $('Create Selenium Session').item.json.value.sessionId }}",
"method": "DELETE",
"options": {}
},
"retryOnFail": false,
"typeVersion": 4.2
},
{
"id": "1b8b1e0c-f465-4963-869c-0e7086922151",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
920,
-1023.3944834469928
],
"parameters": {
"color": 4,
"width": 851.2111300888805,
"height": 1333.3079943516484,
"content": "## N8N Ultimate Scraper - Workflow\n\nThis workflow's objective is to collect data from any website page, whether it requires login or not.\n\nFor example, you can collect the number of stars of the n8n-ultimate-scraper project on GitHub.\n\n## Requirements\n**Selenium Container**: Selenium is an open-source automation framework for web applications, enabling browser control and interaction through scripts in various programming languages.\nYou can deploy the Docker Compose file from the associated GitHub project to set up your Selenium container and configuration: https://github.com/Touxan/n8n-ultimate-scraper\n\n**Residential Proxy Server**: To scrape data at scale without being blocked, I personally recommend GeoNode. They offer affordable, high-quality residential proxies: https://geonode.com/invite/98895\n\n**OpenAI API Key**: For using GPT-4.\n\n## Optional\nSession Cookies Collection: To use login functionality with the n8n Ultimate Scraper, you need to collect session cookies from the target website. You can do this using the extension created for this application in the GitHub project: https://github.com/Touxan/n8n-ultimate-scraper. Follow the installation procedure to use it.\n\n## How to use \nDeploy the project with all the requiremnts and request your webhook.\n\n**Example of request**:\ncurl -X POST http://localhost:5678/webhook-test/yourwebhookid \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"subject\": \"Hugging Face\",\n \"Url\": \"github.com\",\n \"Target data\": [\n {\n \"DataName\": \"Followers\",\n \"description\": \"The number of followers of the GitHub page\"\n },\n {\n \"DataName\": \"Total Stars\",\n \"description\": \"The total numbers of stars on the different repos\"\n }\n ],\n \"cookies\": []\n}'\n\nYou can also scrape link like this : \ncurl -X POST http://localhost:5678/webhook-test/67d77918-2d5b-48c1-ae73-2004b32125f0 \\\n-H \"Content-Type: application/json\" \\\n-d '{\n \"Target Url\": \"https://github.com\",\n \"Target data\": [\n {\n \"DataName\": \"Followers\",\n \"description\": \"The number of followers of the GitHub page\"\n },\n {\n \"DataName\": \"Total Stars\",\n \"description\": \"The total numbers of stars on the different repo\"\n }\n]\n}'\n\n**Note**\nThe maximum nimber of Target data is 5."
},
"typeVersion": 1
},
{
"id": "4d743518-4fcb-4e9f-aff7-a8959a78ccaf",
"name": "Edit Fields (For testing prupose )",
"type": "n8n-nodes-base.set",
"position": [
1160,
540
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "3895040f-0a21-47ee-a73f-d3c7fd6edf36",
"name": "Subject",
"type": "string",
"value": "={{ $json.body.subject }}"
},
{
"id": "304e4240-513f-4c87-ae9d-4efda7d0c4ab",
"name": "Website Domaine",
"type": "string",
"value": "={{ $json.body.Url }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "62b0a416-71a2-4d2b-83f9-8c5465c72006",
"name": "Get ScreenShot 2",
"type": "n8n-nodes-base.httpRequest",
"onError": "continueErrorOutput",
"position": [
6200,
851
],
"parameters": {
"url": "=http://selenium_chrome:4444/wd/hub/session/{{ $('Create Selenium Session').item.json.value.sessionId }}/screenshot",
"options": {}
},
"typeVersion": 4.2
},
{
"id": "6a5b1a08-c47a-435e-8e0b-648cb8282a90",
"name": "Convert to File2",
"type": "n8n-nodes-base.convertToFile",
"onError": "continueErrorOutput",
"position": [
6440,
851
],
"parameters": {
"options": {},
"operation": "toBinary",
"sourceProperty": "value"
},
"typeVersion": 1.1
},
{
"id": "a2aa5d45-5f41-41f7-a8ee-07c145b73d89",
"name": "Go on ip-api.com",
"type": "n8n-nodes-base.httpRequest",
"onError": "continueErrorOutput",
"position": [
5960,
851
],
"parameters": {
"url": "=http://selenium_chrome:4444/wd/hub/session/{{ $('Create Selenium Session').item.json.value.sessionId }}/url",
"method": "POST",
"options": {},
"jsonBody": "={\n \"url\": \"https://ip-api.com/\"\n}\n",
"sendBody": true,
"specifyBody": "json"
},
"retryOnFail": true,
"typeVersion": 4.2
},
{
"id": "8ddde1d2-0b09-45ca-88ef-db24352b095e",
"name": "Delete Session8",
"type": "n8n-nodes-base.httpRequest",
"onError": "continueRegularOutput",
"position": [
6440,
1071
],
"parameters": {
"url": "=http://selenium_chrome:4444/wd/hub/session/{{ $('Create Selenium Session').item.json.value.sessionId }}",
"method": "DELETE",
"options": {}
},
"retryOnFail": false,
"typeVersion": 4.2
},
{
"id": "78ffd8e1-b4b8-444c-8a7d-410172d3a7f8",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
5920,
727
],
"parameters": {
"color": 6,
"width": 784.9798841202522,
"height": 520.0741248156677,
"content": "## Debug IP\n\nThis small debug flow aims to check the IP you're requesting with, in case you're using a proxy"
},
"typeVersion": 1
},
{
"id": "be5de434-5f07-40bc-a1e6-aece9ad211b4",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
1580,
420
],
"parameters": {
"width": 751.8596006980003,
"height": 430.433007240277,
"content": "## Search\n\n**Description** :\nThis part aims to search on Google for the subject and find the URL of the subject page based on the input URL."
},
"typeVersion": 1
},
{
"id": "ffbb3c92-245b-4635-9adf-17d24f236bff",
"name": "Error can't find url",
"type": "n8n-nodes-base.respondToWebhook",
"position": [
2800,
280
],
"parameters": {
"options": {
"responseCode": 404
},
"respondWith": "json",
"responseBody": "{\n \"Error\": \"Can't find url\"\n}"
},
"typeVersion": 1.1
},
{
"id": "088ad72c-907a-409a-9fa4-00a16d396e1b",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
2420,
420
],
"parameters": {
"width": 827.9448220213314,
"height": 502.0185388323068,
"content": "## Selenium Session\n\n**Description**:\nCreation and configuration of the Selenium session."
},
"typeVersion": 1
},
{
"id": "00b8bf19-b34e-42ed-bb2a-3fbfa5f02a25",
"name": "Resize browser window",
"type": "n8n-nodes-base.httpRequest",
"position": [
2920,
560
],
"parameters": {
"url": "=http://selenium_chrome:4444/wd/hub/session/{{ $json.value.sessionId }}/window/rect",
"method": "POST",
"options": {},
"jsonBody": "{\n \"width\": 1920,\n \"height\": 1080,\n \"x\": 0,\n \"y\": 0\n}\n",
"sendBody": true,
"specifyBody": "json"
},
"typeVersion": 4.2
},
{
"id": "007354a1-3f00-4ae9-ab53-54ded5eed563",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"position": [
3500,
-300
],
"parameters": {
"width": 3939.555135735299,
"height": 821.0847869745435,
"content": "## Scrape with cookies session\n\n**Description**\nThis part goes to the extracted URL, injects the cookies passed into the webhook, takes a screenshot of the webpage, and analyzes the image with GPT to extract the targeted data."
},
"typeVersion": 1
},
{
"id": "5ab44e1b-6878-4af5-bfd8-1f1e5cbee3a7",
"name": "Sticky Note5",
"type": "n8n-nodes-base.stickyNote",
"position": [
3500,
580
],
"parameters": {
"width": 3336.952424000919,
"height": 821.0847869745435,
"content": "## Scrape without cookies session\n\n**Description**\nSame as the 'Scrape with cookies session' flow, but without the cookie injection"
},
"typeVersion": 1
},
{
"id": "4fc7e290-0c60-4efe-ac3f-eb71ce5e457b",
"name": "OpenAI",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
6340,
-20
],
"parameters": {
"text": "=Analyse this image and extract revlant infromation about this subject : {{ $('Webhook').item.json.body.subject }}. \n\nIf the webpage seem block by waf, or don't have any relant information about the subject reurn BLOCK with out any aditinonal information.",
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4o",
"cachedResultName": "GPT-4O"
},
"options": {
"detail": "auto",
"maxTokens": 300
},
"resource": "image",
"inputType": "base64",
"operation": "analyze"
},
"credentials": {
"openAiApi": {
"id": "FmszNHDDVS32ud21",
"name": "OpenAi account"
}
},
"typeVersion": 1.5
},
{
"id": "b039ed2a-94da-4a37-b794-7fb1721a8ab3",
"name": "OpenAI1",
"type": "@n8n/n8n-nodes-langchain.openAi",
"onError": "continueErrorOutput",
"position": [
4780,
840
],
"parameters": {
"text": "=Analyse this image and extract revlant infromation about this subject : {{ $('Webhook').item.json.body.subject }}. \n\nIf the webpage seem block by waf, or don't have any relant information about the subject reurn BLOCK with out any aditinonal information.",
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4o",
"cachedResultName": "GPT-4O"
},
"options": {
"detail": "auto",
"maxTokens": 300
},
"resource": "image",
"inputType": "base64",
"operation": "analyze"
},
"credentials": {
"openAiApi": {
"id": "FmszNHDDVS32ud21",
"name": "OpenAi account"
}
},
"typeVersion": 1.5
},
{
"id": "c69364ce-c7e3-4f7a-ae0c-bad97643da30",
"name": "Information Extractor1",
"type": "@n8n/n8n-nodes-langchain.informationExtractor",
"position": [
5400,
920
],
"parameters": {
"text": "={{ $('OpenAI1').item.json.content }}",
"options": {
"systemPromptTemplate": "You are an expert extraction algorithm.\nOnly extract relevant information from the text.\nIf you do not know the value of an attribute asked to extract, set the attribute's value to NA."
},
"attributes": {
"attributes": [
{
"name": "={{ $('Webhook').item.json.body['Target data'][0].DataName }}",
"description": "={{ $('Webhook').item.json.body['Target data'][0].description }}"
},
{
"name": "={{ $('Webhook').item.json.body['Target data'][1].DataName }}",
"description": "=The total number of stars on all project"
},
{
"name": "={{ $('Webhook').item.json.body['Target data'][2].DataName }}",
"description": "={{ $('Webhook').item.json.body['Target data'][2].description }}"
},
{
"name": "={{ $('Webhook').item.json.body['Target data'][3].DataName }}",
"description": "={{ $('Webhook').item.json.body['Target data'][3].description }}"
},