{
  "name": "Site Scraper → Screenshot → Partner Analiz",
  "nodes": [
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [240, 300],
      "id": "10cf88d5-0df8-4b39-ba6b-5507bc5cfeb0",
      "name": "When clicking 'Execute workflow'"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "domain-field",
              "name": "domain",
              "value": "muglasurucukursu.com",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "90ed9042-f1e0-4b75-a986-06d266974b9a",
      "name": "Set Domain",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [480, 300]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://sbq038z8y8yb8z4s2whet0q0.65.109.236.58.sslip.io/scrape",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "x-api-key",
              "value": "AyrisScraperSecr3tKey2026"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"url\": \"https://{{ $json.domain }}\"\n}",
        "options": {}
      },
      "id": "d19cc658-e65e-489e-b23c-ea02a23a9b94",
      "name": "Link Scraper API",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [720, 300]
    },
    {
      "parameters": {
        "resource": "folder",
        "name": "={{ $('Set Domain').first().json.domain }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "folderId": {
          "__rl": true,
          "value": "1jNcMOUaTZmi7SJIF4xShGjEvEymENDZ0",
          "mode": "list",
          "cachedResultName": "WebSiteScrenShots",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1jNcMOUaTZmi7SJIF4xShGjEvEymENDZ0"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [960, 300],
      "id": "e0fb79cd-8adc-449a-b0de-800e3451e5f2",
      "name": "Create Folder",
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "UobQnjEvaIAp1tOm",
          "name": "Google Drive account"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "const links = $('Link Scraper API').first().json.links || [];\nconst folderId = $('Create Folder').first().json.id;\n\nreturn links.slice(0, 10).map(l => ({\n  json: {\n    label: l.label,\n    url: l.url,\n    folderId: folderId\n  }\n}));"
      },
      "id": "8e0dea68-2437-416b-b963-ab1d1f97eca1",
      "name": "Prepare URLs",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [1200, 300]
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [1440, 300],
      "id": "daf4a716-92bf-497d-b017-bdca05485a9f",
      "name": "Loop Over Items"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.screencapr.com/api/screenshot",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"url\": \"{{ $('Prepare URLs').first().json.url }}\",\n  \"options\": {\n    \"width\": 1440,\n    \"height\": 900,\n    \"format\": \"jpeg\",\n    \"quality\": 85,\n    \"fullPage\": true,\n    \"timeout\": 30000\n  }\n}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file",
              "outputPropertyName": "screenshot"
            }
          },
          "timeout": 60000
        }
      },
      "id": "ce61f453-59da-4592-8bf3-ff269debb57f",
      "name": "ScreenCapr Screenshot",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [1680, 300]
    },
    {
      "parameters": {
        "inputDataFieldName": "screenshot",
        "name": "={{ $('Loop Over Items').item.json.label }}.jpg",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "folderId": {
          "__rl": true,
          "value": "={{ $('Loop Over Items').item.json.folderId }}",
          "mode": "id"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [1920, 300],
      "id": "8b087127-57f8-430e-b3d2-8a66c57561fa",
      "name": "Upload to Drive",
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "UobQnjEvaIAp1tOm",
          "name": "Google Drive account"
        }
      }
    },
    {
      "parameters": {
        "resource": "file",
        "operation": "list",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "folderId": {
          "__rl": true,
          "value": "={{ $('Create Folder').first().json.id }}",
          "mode": "id"
        },
        "returnAll": false,
        "limit": 2,
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [1680, 80],
      "id": "f1a23456-0001-4abc-8def-111111111111",
      "name": "List Drive Files",
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "UobQnjEvaIAp1tOm",
          "name": "Google Drive account"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// Sadece ilk dosyayı al\nreturn [$input.first()];"
      },
      "id": "f2b34567-0002-4abc-8def-222222222222",
      "name": "Get First File",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [1920, 80]
    },
    {
      "parameters": {
        "resource": "file",
        "operation": "download",
        "fileId": {
          "__rl": true,
          "value": "={{ $json.id }}",
          "mode": "id"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [2160, 80],
      "id": "f3c45678-0003-4abc-8def-333333333333",
      "name": "Download Screenshot",
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "UobQnjEvaIAp1tOm",
          "name": "Google Drive account"
        }
      }
    },
    {
      "parameters": {
        "resource": "image",
        "operation": "analyze",
        "modelId": {
          "__rl": true,
          "value": "models/gemini-2.5-flash",
          "mode": "list",
          "cachedResultName": "models/gemini-2.5-flash"
        },
        "text": "Bu web sitesi ekran görüntüsünü analiz et ve aşağıdaki JSON formatında döndür. Sadece JSON döndür, başka açıklama ekleme:\n\n{\n  \"partner_ismi\": \"Firmanın tam adı\",\n  \"monogram\": \"2-3 harfli kısaltma (örn: AYR, SCC)\",\n  \"kategori\": \"Tek kelime sektör (Sağlık, Enerji, Restoran, Eğitim, Ulaşım, İnşaat, Teknoloji vb.)\",\n  \"aciklama\": \"Firmayı anlatan 1-2 cümle\"\n}",
        "inputType": "binary",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "typeVersion": 1.1,
      "position": [2400, 80],
      "id": "f4d56789-0004-4abc-8def-444444444444",
      "name": "Gemini Analiz",
      "credentials": {
        "googlePalmApi": {
          "id": "Bu5nSnIxNY3DvfGa",
          "name": "n8nautomation"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "const raw = $input.first().json.text || $input.first().json.content || '';\n\n// JSON bloğunu temizle\nconst cleaned = raw.replace(/```json/g, '').replace(/```/g, '').trim();\n\nlet parsed;\ntry {\n  parsed = JSON.parse(cleaned);\n} catch(e) {\n  // JSON parse başarısız olursa fallback\n  parsed = {\n    partner_ismi: $('Set Domain').first().json.domain,\n    monogram: $('Set Domain').first().json.domain.substring(0, 3).toUpperCase(),\n    kategori: 'Diğer',\n    aciklama: 'Otomatik analiz başarısız oldu.'\n  };\n}\n\nreturn [{ json: parsed }];"
      },
      "id": "f5e67890-0005-4abc-8def-555555555555",
      "name": "Parse JSON",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [2640, 80]
    },
    {
      "parameters": {
        "operation": "insert",
        "schema": {
          "__rl": true,
          "mode": "list",
          "value": "public"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "partners"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "name": "={{ $json.partner_ismi }}",
            "monogram": "={{ $json.monogram }}",
            "category": "={{ $json.kategori }}",
            "bio": "={{ $json.aciklama }}",
            "start_year": 2026,
            "domain": "={{ $('Set Domain').first().json.domain }}"
          }
        },
        "options": {}
      },
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.5,
      "position": [2880, 80],
      "id": "f6f78901-0006-4abc-8def-666666666666",
      "name": "PostgreSQL Insert",
      "credentials": {
        "postgres": {
          "id": "POSTGRES_CREDENTIAL_ID",
          "name": "Postgres account"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "When clicking 'Execute workflow'": {
      "main": [[{ "node": "Set Domain", "type": "main", "index": 0 }]]
    },
    "Set Domain": {
      "main": [[{ "node": "Link Scraper API", "type": "main", "index": 0 }]]
    },
    "Link Scraper API": {
      "main": [[{ "node": "Create Folder", "type": "main", "index": 0 }]]
    },
    "Create Folder": {
      "main": [[{ "node": "Prepare URLs", "type": "main", "index": 0 }]]
    },
    "Prepare URLs": {
      "main": [[{ "node": "Loop Over Items", "type": "main", "index": 0 }]]
    },
    "Loop Over Items": {
      "main": [
        [{ "node": "List Drive Files", "type": "main", "index": 0 }],
        [{ "node": "ScreenCapr Screenshot", "type": "main", "index": 0 }]
      ]
    },
    "ScreenCapr Screenshot": {
      "main": [[{ "node": "Upload to Drive", "type": "main", "index": 0 }]]
    },
    "Upload to Drive": {
      "main": [[{ "node": "Loop Over Items", "type": "main", "index": 0 }]]
    },
    "List Drive Files": {
      "main": [[{ "node": "Get First File", "type": "main", "index": 0 }]]
    },
    "Get First File": {
      "main": [[{ "node": "Download Screenshot", "type": "main", "index": 0 }]]
    },
    "Download Screenshot": {
      "main": [[{ "node": "Gemini Analiz", "type": "main", "index": 0 }]]
    },
    "Gemini Analiz": {
      "main": [[{ "node": "Parse JSON", "type": "main", "index": 0 }]]
    },
    "Parse JSON": {
      "main": [[{ "node": "PostgreSQL Insert", "type": "main", "index": 0 }]]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false
  },
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "79d13d1a6fcae5c2e451a2b02247a15904071a685f973aa3c0464bf9f4cd5f82"
  },
  "id": "UDHv1qTfRRi1Q-Vqt47m1",
  "tags": []
}
