{
  "name": "Lesson 8 Scrapping",
  "nodes": [
    {
      "parameters": {
        "operation": "extractHtmlContent",
        "dataPropertyName": "items",
        "extractionValues": {
          "values": [
            {
              "key": "name",
              "cssSelector": ".col1"
            },
            {
              "key": "price",
              "cssSelector": "div:nth-of-type(2) "
            }
          ]
        },
        "options": {}
      },
      "id": "a650f253-5d09-43fb-b234-8c1907afccac",
      "name": "HTML - извлечь текст из тегов1",
      "type": "n8n-nodes-base.html",
      "typeVersion": 1,
      "position": [
        -360,
        680
      ]
    },
    {
      "parameters": {
        "operation": "formatDate",
        "date": "={{ $('Schedule Trigger - в полдень1').item.json.timestamp }}",
        "format": "custom",
        "customFormat": "dd.MM.yyyy",
        "outputFieldName": "date",
        "options": {}
      },
      "id": "60c651c1-9480-403c-a743-2edae02cd0ea",
      "name": "Формат DD.MM.YYYYY",
      "type": "n8n-nodes-base.dateTime",
      "typeVersion": 2,
      "position": [
        -20,
        680
      ],
      "executeOnce": false
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 12
            }
          ]
        }
      },
      "id": "b94be540-bfc4-4644-bb76-dbae695f38f2",
      "name": "Schedule Trigger - в полдень1",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1,
      "position": [
        -1600,
        680
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "https://docs.google.com/spreadsheets/d/135QTdLbFwM1iEPIOWCPgEu-Aip0eyeV1Sy4M3Cze-tU/edit#gid=1847821208",
          "mode": "url",
          "__regex": "https:\\/\\/(?:drive|docs)\\.google\\.com(?:\\/.*|)\\/d\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)"
        },
        "sheetName": {
          "__rl": true,
          "value": "https://docs.google.com/spreadsheets/d/135QTdLbFwM1iEPIOWCPgEu-Aip0eyeV1Sy4M3Cze-tU/edit#gid=0",
          "mode": "url",
          "__regex": "https:\\/\\/docs\\.google\\.com/spreadsheets\\/d\\/[0-9a-zA-Z\\-_]+\\/edit\\#gid=([0-9]+)"
        },
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "name",
              "fieldValue": "={{ $('HTML - извлечь текст из тегов1').item.json.name }}"
            }
          ]
        },
        "options": {}
      },
      "id": "af98add5-c570-4467-8068-784d0c7ac163",
      "name": "Вставить названия1",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 3,
      "position": [
        340,
        520
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "11",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "url": "https://artemdzyuba.ru/?page_id=5823",
        "options": {}
      },
      "id": "508d844d-5c0a-46f4-9a68-c139f9ad01df",
      "name": "HTTP Request - получить веб-страницу",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 3,
      "position": [
        -1360,
        680
      ]
    },
    {
      "parameters": {
        "operation": "extractHtmlContent",
        "extractionValues": {
          "values": [
            {
              "key": "items",
              "cssSelector": ".table-container > div",
              "returnValue": "html",
              "returnArray": true
            }
          ]
        },
        "options": {}
      },
      "id": "15a09683-b0f0-4ba8-be7b-aba8535f057f",
      "name": "HTML - извлечь строки",
      "type": "n8n-nodes-base.html",
      "typeVersion": 1,
      "position": [
        -1120,
        680
      ]
    },
    {
      "parameters": {
        "fieldToSplitOut": "items",
        "options": {}
      },
      "id": "e8e2c9ee-3f70-4c7f-815d-98d1877b5f7f",
      "name": "Разделить  на элементы",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 2,
      "position": [
        -880,
        680
      ]
    },
    {
      "parameters": {
        "operation": "limit",
        "maxItems": "={{ $input.all().length - 1 }}",
        "keep": "lastItems"
      },
      "id": "e85e15db-1fdb-41b8-a6c4-f2f1713578cd",
      "name": "Выбросить первый элемент",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 2.1,
      "position": [
        -640,
        680
      ]
    },
    {
      "parameters": {
        "operation": "formatDate",
        "date": "={{ $('Schedule Trigger - в полдень1').item.json.timestamp }}",
        "format": "custom",
        "customFormat": "dd.MM.yyyy",
        "outputFieldName": "date",
        "options": {}
      },
      "id": "ae5272a5-1524-4e0c-945a-f22f96b9d3b9",
      "name": "Формат DD.MM.YYYYY1",
      "type": "n8n-nodes-base.dateTime",
      "typeVersion": 2,
      "position": [
        -80,
        1440
      ],
      "executeOnce": true
    },
    {
      "parameters": {
        "content": "### Альтернативный вариант\nПосле одного из обновлений стало невозможно выбирать колонку в Google Sheets динамически.\n\nПоэтому таблицу можно перевернуть - чтобы даты были по строкам. И каждый день добавлять новый ряд дат.",
        "height": 201.3796407185629,
        "width": 315.42035928143713
      },
      "id": "4e7b03f9-1d63-4e4f-aa79-d4b80536b58f",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -480,
        1360
      ]
    },
    {
      "parameters": {
        "content": "### Выполняется 1 раз",
        "height": 80,
        "width": 201.11137724550895
      },
      "id": "c12f28d3-d586-4e08-befe-4974d70fb4b9",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -120,
        1600
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "135QTdLbFwM1iEPIOWCPgEu-Aip0eyeV1Sy4M3Cze-tU",
          "mode": "list",
          "cachedResultName": "HTML Extraction (fantasy oil prices)",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/135QTdLbFwM1iEPIOWCPgEu-Aip0eyeV1Sy4M3Cze-tU/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": 1663086665,
          "mode": "list",
          "cachedResultName": "Даты - построчно",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/135QTdLbFwM1iEPIOWCPgEu-Aip0eyeV1Sy4M3Cze-tU/edit#gid=1663086665"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Дата": "={{ $json.date }}",
            "Эльфийская эссенция": "={{ $('HTML - извлечь текст из тегов1').item.json.price }}",
            "Волшебное зелье": "={{ $('HTML - извлечь текст из тегов1').item.json.price }}",
            "Драконий огонь": "={{ $('HTML - извлечь текст из тегов1').item.json.price }}",
            "Фениксовый эликсир": "={{ $('HTML - извлечь текст из тегов1').item.json.price }}",
            "Гномий гранит": "={{ $('HTML - извлечь текст из тегов1').item.json.price }}",
            "Волшебный кристалл": "={{ $('HTML - извлечь текст из тегов1').item.json.price }}",
            "Пегасовый покров": "={{ $('HTML - извлечь текст из тегов1').item.json.price }}",
            "Химерий хрусталь": "={{ $('HTML - извлечь текст из тегов1').item.json.price }}",
            "Грифоний гнев": "={{ $('HTML - извлечь текст из тегов1').item.json.price }}",
            "Вампирская воля": "={{ $('HTML - извлечь текст из тегов1').item.json.price }}",
            "Единорожий эфир": "={{ $('HTML - извлечь текст из тегов1').item.json.price }}",
            "Змеиная смола": "={{ $('HTML - извлечь текст из тегов1').item.json.price }}",
            "Фейерверк фантазии": "={{ $('HTML - извлечь текст из тегов1').item.json.price }}",
            "Орлиный перст": "={{ $('HTML - извлечь текст из тегов1').item.json.price }}",
            "Циклоповый шторм": "={{ $('HTML - извлечь текст из тегов1').item.json.price }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Дата",
              "displayName": "Дата",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Эльфийская эссенция",
              "displayName": "Эльфийская эссенция",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Волшебное зелье",
              "displayName": "Волшебное зелье",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Драконий огонь",
              "displayName": "Драконий огонь",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Фениксовый эликсир",
              "displayName": "Фениксовый эликсир",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Гномий гранит",
              "displayName": "Гномий гранит",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Волшебный кристалл",
              "displayName": "Волшебный кристалл",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Пегасовый покров",
              "displayName": "Пегасовый покров",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Химерий хрусталь",
              "displayName": "Химерий хрусталь",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Грифоний гнев",
              "displayName": "Грифоний гнев",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Вампирская воля",
              "displayName": "Вампирская воля",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Единорожий эфир",
              "displayName": "Единорожий эфир",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Змеиная смола",
              "displayName": "Змеиная смола",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Фейерверк фантазии",
              "displayName": "Фейерверк фантазии",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Орлиный перст",
              "displayName": "Орлиный перст",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Циклоповый шторм",
              "displayName": "Циклоповый шторм",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ]
        },
        "options": {
          "cellFormat": "USER_ENTERED"
        }
      },
      "id": "4bc41130-367a-45a1-9847-1561c202be4e",
      "name": "Add record",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [
        240,
        1440
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "11",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "string": [
            {
              "name": "name",
              "value": "={{ $('HTML - извлечь текст из тегов1').item.json.name }}"
            }
          ],
          "number": [
            {
              "name": "={{ $json[\"date\"] }}",
              "value": "={{ $('HTML - извлечь текст из тегов1').item.json.price }}"
            }
          ]
        },
        "options": {
          "dotNotation": false
        }
      },
      "id": "76013e33-e60d-4528-a071-148f2e6cc9bb",
      "name": "Прописать свойства для автоподбора",
      "type": "n8n-nodes-base.set",
      "typeVersion": 2,
      "position": [
        280,
        980
      ]
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "value": "135QTdLbFwM1iEPIOWCPgEu-Aip0eyeV1Sy4M3Cze-tU",
          "mode": "list",
          "cachedResultName": "HTML Extraction (fantasy oil prices)",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/135QTdLbFwM1iEPIOWCPgEu-Aip0eyeV1Sy4M3Cze-tU/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/135QTdLbFwM1iEPIOWCPgEu-Aip0eyeV1Sy4M3Cze-tU/edit#gid=0"
        },
        "columnToMatchOn": "name",
        "valueToMatchOn": "={{ $('HTML - извлечь текст из тегов1').item.json.name }}",
        "fieldsUi": {
          "values": [
            {
              "column": "={{ $json.date }}",
              "fieldValue": "={{ $('HTML - извлечь текст из тегов1').item.json.price }}"
            }
          ]
        },
        "options": {
          "cellFormat": "USER_ENTERED"
        }
      },
      "id": "801e5e99-b920-4708-aa36-302116076cb4",
      "name": "Обновить записи (как в видеоуроке)",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 3,
      "position": [
        540,
        760
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "11",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "value": "135QTdLbFwM1iEPIOWCPgEu-Aip0eyeV1Sy4M3Cze-tU",
          "mode": "list",
          "cachedResultName": "HTML Extraction (fantasy oil prices)",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/135QTdLbFwM1iEPIOWCPgEu-Aip0eyeV1Sy4M3Cze-tU/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/135QTdLbFwM1iEPIOWCPgEu-Aip0eyeV1Sy4M3Cze-tU/edit#gid=0"
        },
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {},
          "matchingColumns": [
            "name"
          ],
          "schema": [
            {
              "id": "name",
              "displayName": "name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "09.07.2023",
              "displayName": "09.07.2023",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "10.07.2023",
              "displayName": "10.07.2023",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "11.07.2023",
              "displayName": "11.07.2023",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "12.07.2023",
              "displayName": "12.07.2023",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "30.08.2023",
              "displayName": "30.08.2023",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "31.08.2023",
              "displayName": "31.08.2023",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "01.09.2023",
              "displayName": "01.09.2023",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "02.09.2023",
              "displayName": "02.09.2023",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "03.09.2023",
              "displayName": "03.09.2023",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "04.09.2023",
              "displayName": "04.09.2023",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "05.09.2023",
              "displayName": "05.09.2023",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "06.09.2023",
              "displayName": "06.09.2023",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "07.09.2023",
              "displayName": "07.09.2023",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "08.09.2023",
              "displayName": "08.09.2023",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "09.09.2023",
              "displayName": "09.09.2023",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "10.09.2023",
              "displayName": "10.09.2023",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "11.09.2023",
              "displayName": "11.09.2023",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "12.09.2023",
              "displayName": "12.09.2023",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "30",
              "displayName": "30",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "date",
              "displayName": "date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            }
          ]
        },
        "options": {
          "cellFormat": "USER_ENTERED"
        }
      },
      "id": "394b7ea0-f9a4-4a14-b369-3b962298cb08",
      "name": "Обновить записи (по-новому)",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [
        540,
        980
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "11",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "content": "### Новый вариант\nПосле обновления, выбор столбца Google Sheets стал невозможен.\n\nПоэтому возможен другой вариант. В узле \"Set\" оставить поле с динамическим названием - текущей датой. А в Google Sheets включить автомэппинг.\n\nВ узле Set надо отключить dot notation, чтобы точки в записи даты  не мешали.",
        "height": 253.15571736526954,
        "width": 345.58850299401206
      },
      "id": "8ad1fe09-fcee-4b37-abd5-5c42001df937",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -60,
        1040
      ]
    }
  ],
  "pinData": {},
  "connections": {
    "HTML - извлечь текст из тегов1": {
      "main": [
        [
          {
            "node": "Формат DD.MM.YYYYY",
            "type": "main",
            "index": 0
          },
          {
            "node": "Формат DD.MM.YYYYY1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Формат DD.MM.YYYYY": {
      "main": [
        [
          {
            "node": "Обновить записи (как в видеоуроке)",
            "type": "main",
            "index": 0
          },
          {
            "node": "Вставить названия1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Прописать свойства для автоподбора",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger - в полдень1": {
      "main": [
        [
          {
            "node": "HTTP Request - получить веб-страницу",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request - получить веб-страницу": {
      "main": [
        [
          {
            "node": "HTML - извлечь строки",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTML - извлечь строки": {
      "main": [
        [
          {
            "node": "Разделить  на элементы",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Разделить  на элементы": {
      "main": [
        [
          {
            "node": "Выбросить первый элемент",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Выбросить первый элемент": {
      "main": [
        [
          {
            "node": "HTML - извлечь текст из тегов1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Формат DD.MM.YYYYY1": {
      "main": [
        [
          {
            "node": "Add record",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Прописать свойства для автоподбора": {
      "main": [
        [
          {
            "node": "Обновить записи (по-новому)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {},
  "versionId": "47e43db5-d2b7-4e02-a550-955f40329765",
  "id": "ZnN0Vk2hJVTji06j",
  "meta": {
    "instanceId": "62148517c718afe88189b4557f5264eca24fb302b44a11226f98636805acbeef"
  },
  "tags": [
    {
      "id": "2",
      "createdAt": "2023-06-22T04:56:17.812Z",
      "updatedAt": "2023-06-22T04:56:17.812Z",
      "name": "n8n business course"
    }
  ]
}