Index: phonelux_scrappers/scrappers/a1_scrapper.py
===================================================================
--- phonelux_scrappers/scrappers/a1_scrapper.py	(revision b68ae8d3cc34d054d169fb34943b9fcd77bff7c2)
+++ phonelux_scrappers/scrappers/a1_scrapper.py	(revision ffd50db1e5e2b9839ba7546d8ca44b600150bd71)
@@ -1,28 +1,37 @@
 import unicodedata
 from datetime import datetime
-
+import json
 import psycopg2
 import config_read
 from bs4 import BeautifulSoup
 import requests
+import sys
+import unicodedata
 
-import sys
+from classes.phoneoffer import PhoneOffer
 
 file_path = 'outputfile.txt'
 sys.stdout = open(file_path, "w")
 
-# Call to read the configuration file and connect to database
-cinfo = config_read.get_databaseconfig("../postgresdb.config")
-db_connection = psycopg2.connect(
-    database=cinfo[0],
-    host=cinfo[1],
-    user=cinfo[2],
-    password=cinfo[3]
-)
-cur = db_connection.cursor()
-
 offer_shop = "A1"  # offer shop
 last_updated = datetime.now().date()
 is_validated = False
+
+# A1 phone offers that are already in database
+
+offers = json.loads(unicodedata.normalize('NFKD', requests.get('http://localhost:8080/phoneoffer/shop/a1').text))
+
+database_offers = []
+
+for offer in offers:
+    phoneOffer = PhoneOffer(offer['id'], offer['offer_shop'], offer['offer_name'], offer['price'],
+                            offer['ram_memory'],
+                            offer['rom_memory'], offer['color'], offer['front_camera'], offer['back_camera'],
+                            offer['chipset'], offer['battery'], offer['operating_system'], offer['cpu'],
+                            offer['image_url'],
+                            offer['offer_url'], offer['last_updated'], offer['is_validated'],
+                            offer['offer_description'],
+                            offer['offer_shop_code'])
+    database_offers.append(phoneOffer)
 
 a1_url = 'https://www.a1.mk/webshop/mk/phones'
@@ -34,7 +43,9 @@
     .find_all('div', {'class', 'dvc-idtfr by4'})
 
+new_offers = []
+
 for phone in phones:
     brand = phone.get('data-brand').strip()
-    offer_name = brand+" "+phone.get('data-model').strip()
+    offer_name = brand + " " + phone.get('data-model').strip()
 
     # if brand not in offer_name:
@@ -77,4 +88,6 @@
     battery = None
     front_camera = None
+    chipset = None
+    offer_description = None
 
     for row in table_rows:
@@ -100,14 +113,49 @@
             front_camera = row.get_text().replace('Предна камера', '').strip()
 
-    insert_script = 'INSERT INTO phone_offers (offer_shop, brand, offer_name, price, image_url, offer_url,' \
-                    'ram_memory, rom_memory, battery, back_camera, front_camera, color, cpu, ' \
-                    'operating_system, offer_shop_code, last_updated, is_validated)' \
-                    ' VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s);'
-    insert_value = (offer_shop, brand, offer_name, price, image_url, offer_url, ram_memory, rom_memory,
-                    battery, back_camera, front_camera, color, cpu, operating_system, offer_shop_code,
-                    last_updated, is_validated)
-    cur.execute(insert_script, insert_value)
-    db_connection.commit()
+    new_offers.append(PhoneOffer(offer_shop, offer_name, price, ram_memory, rom_memory,
+                                 color, front_camera, back_camera, chipset, battery, operating_system, cpu, image_url,
+                                 offer_url, last_updated, is_validated, offer_description, offer_shop_code))
 
-cur.close()
-db_connection.close()
+for new_offer in new_offers:
+    flag = False
+    flag_price = False
+    offer_id = None
+
+    for old_offer in database_offers:
+
+        if new_offer.offer_shop_code == old_offer.offer_shop_code:
+            flag = True
+            if new_offer.price != old_offer.price:
+                flag_price = True
+                offer_id = old_offer.offer_id
+
+    if flag:
+        # print('ALREADY IN DATABASE')
+        # print(new_offer)
+        # if it's already in database, check PRICE and if it's changed, change it !!!!!!
+        if flag_price:
+            print('PRICE CHANGED!')  # CHANGE PRICE
+            print('offer id: ' + str(offer_id))
+            headers = {'Content-type': 'application/json'}
+            requests.put('http://localhost:8080/phoneoffer/' + str(offer_id) + '/changeprice/' + str(new_offer.price),
+                         headers=headers)
+    else:
+        print('ADDED')  # ADD OFFER
+        print(new_offer)
+        headers = {'Content-type': 'application/json'}
+        requests.post('http://localhost:8080/phoneoffer/addoffer', headers=headers, data=json.dumps(new_offer.__dict__,
+                                                                                                    default=str))
+
+print('------------------------------------')
+
+for old_offer in database_offers:
+    flag = False
+    for new_offer in new_offers:
+        if old_offer.offer_shop_code == new_offer.offer_shop_code:
+            flag = True
+
+    if not flag:
+        print('OFFER DELETED')
+        print(old_offer)
+        # DELETE OFFER
+        requests.delete('http://localhost:8080/phoneoffer/deleteoffer/' + str(old_offer.offer_id))
Index: phonelux_scrappers/scrappers/akcija_scrapper.py
===================================================================
--- phonelux_scrappers/scrappers/akcija_scrapper.py	(revision b68ae8d3cc34d054d169fb34943b9fcd77bff7c2)
+++ phonelux_scrappers/scrappers/akcija_scrapper.py	(revision ffd50db1e5e2b9839ba7546d8ca44b600150bd71)
@@ -1,2 +1,3 @@
+import json
 from datetime import datetime
 
@@ -7,21 +8,32 @@
 import unicodedata
 import sys
+from classes.phoneoffer import PhoneOffer
 
-# file_path = '../outputfile.txt'
-# sys.stdout = open(file_path, "w")
+file_path = 'outputfile.txt'
+sys.stdout = open(file_path, "w")
 
-# Call to read the configuration file and connect to database
-cinfo = config_read.get_databaseconfig("../postgresdb.config")
-db_connection = psycopg2.connect(
-    database=cinfo[0],
-    host=cinfo[1],
-    user=cinfo[2],
-    password=cinfo[3]
-)
-cur = db_connection.cursor()
 
 offer_shop = "Akcija"  # offer shop
 last_updated = datetime.now().date()
 is_validated = False
+
+# Akcija phone offers that are already in database
+
+offers = json.loads(unicodedata.normalize('NFKD', requests.get('http://localhost:8080/phoneoffer/shop/akcija').text))
+
+database_offers = []
+
+for offer in offers:
+    phoneOffer = PhoneOffer(offer['id'], offer['offer_shop'], offer['offer_name'], offer['price'],
+                            offer['ram_memory'],
+                            offer['rom_memory'], offer['color'], offer['front_camera'], offer['back_camera'],
+                            offer['chipset'], offer['battery'], offer['operating_system'], offer['cpu'],
+                            offer['image_url'],
+                            offer['offer_url'], offer['last_updated'], offer['is_validated'],
+                            offer['offer_description'],
+                            offer['offer_shop_code'])
+    database_offers.append(phoneOffer)
+
+new_offers = []
 
 i = 0
@@ -51,4 +63,15 @@
         soup2 = BeautifulSoup(response2.text, 'html.parser')
 
+        back_camera = None
+        operating_system = None
+        chipset = None
+        battery = None
+        ram_memory = None
+        rom_memory = None
+        cpu = None
+        front_camera = None
+        color = None
+        offer_shop_code = None
+
         specifications = soup2.find('main', {'id': 'content'}) \
             .find_all('div', {'class', 'container'})[1].find('div', {'class', 'mb-14'}) \
@@ -62,13 +85,51 @@
                                                        str(specification.get_text(separator='\n').strip())) + "\n"
 
-        insert_script = 'INSERT INTO phone_offers (offer_shop, brand,' \
-                        ' offer_name, price, image_url, offer_url, last_updated, is_validated, offer_description) ' \
-                        'VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s);'
-        insert_value = (offer_shop, brand, offer_name, price, image_url, offer_url,
-                        last_updated, is_validated, offer_description)
-        cur.execute(insert_script, insert_value)
-        db_connection.commit()
+        new_offers.append(PhoneOffer(offer_shop, offer_name, price, ram_memory, rom_memory,
+                                     color, front_camera, back_camera, chipset, battery, operating_system, cpu,
+                                     image_url,
+                                     offer_url, last_updated, is_validated, offer_description, offer_shop_code))
     i += 20
 
-cur.close()
-db_connection.close()
+for new_offer in new_offers:
+    flag = False
+    flag_price = False
+    offer_id = None
+
+    for old_offer in database_offers:
+
+        if new_offer.offer_name == old_offer.offer_name:
+            flag = True
+            if new_offer.price != old_offer.price:
+                flag_price = True
+                offer_id = old_offer.offer_id
+
+    if flag:
+        # print('ALREADY IN DATABASE')
+        # print(new_offer)
+        # if it's already in database, check PRICE and if it's changed, change it !!!!!!
+        if flag_price:
+            print('PRICE CHANGED!')  # CHANGE PRICE
+            print('offer id: ' + str(offer_id))
+            headers = {'Content-type': 'application/json'}
+            requests.put('http://localhost:8080/phoneoffer/' + str(offer_id) + '/changeprice/' + str(new_offer.price),
+                         headers=headers)
+    else:
+        print('ADDED')  # ADD OFFER
+        print(new_offer)
+        headers = {'Content-type': 'application/json'}
+        requests.post('http://localhost:8080/phoneoffer/addoffer',
+                      headers=headers, data=json.dumps(new_offer.__dict__, default=str))
+
+print('------------------------------------')
+
+for old_offer in database_offers:
+    flag = False
+    for new_offer in new_offers:
+        if old_offer.offer_name == new_offer.offer_name:
+            flag = True
+
+    if not flag:
+        print('OFFER DELETED')
+        print(old_offer)
+        # DELETE OFFER
+        requests.delete('http://localhost:8080/phoneoffer/deleteoffer/' + str(old_offer.offer_id))
Index: phonelux_scrappers/scrappers/anhoch_scrapper.py
===================================================================
--- phonelux_scrappers/scrappers/anhoch_scrapper.py	(revision b68ae8d3cc34d054d169fb34943b9fcd77bff7c2)
+++ 	(revision )
@@ -1,90 +1,0 @@
-import time
-from datetime import datetime
-import psycopg2
-from selenium import webdriver
-from selenium.webdriver.common.by import By
-from selenium.webdriver.support.ui import WebDriverWait
-from selenium.webdriver.support import expected_conditions as EC
-
-import config_read
-from bs4 import BeautifulSoup
-import requests
-import unicodedata
-import sys
-
-file_path = '../outputfile.txt'
-sys.stdout = open(file_path, "w")
-
-# Call to read the configuration file and connect to database
-cinfo = config_read.get_databaseconfig("../postgresdb.config")
-db_connection = psycopg2.connect(
-    database=cinfo[0],
-    host=cinfo[1],
-    user=cinfo[2],
-    password=cinfo[3]
-)
-cur = db_connection.cursor()
-
-
-def scrape_function(driver1, i):
-    offer_shop = "Anhoch"  # offer shop
-    last_updated = datetime.now().date()
-    is_validated = False
-
-    anhoch_html = driver1.page_source
-    soup1 = BeautifulSoup(anhoch_html, 'html.parser')
-    active_li = soup1.find('div', {'class': 'adjust-elems pagination pagination-centered'}).find('li', {'class': 'active'})
-
-    li_element = int(active_li.get_text().strip())
-
-    print('page: '+str(li_element))
-
-    if int(active_li.get_text().strip()) == i:
-        phones = soup1.find('section', {'id': 'main'}).find('div', {'class': 'span8'}) \
-            .find('div', {'class': 'products'}).find_all('li')
-        for phone in phones:
-            offer_url = phone.find('a').get('href')
-            image_url = phone.find('a').find('img').get('src')
-            offer_name = phone.find('div', {'class': 'product-name'}).find('a').get_text().strip()
-            price = int(phone.get('data-price'))
-            brand = phone.find('div', {'class': 'product-price'}).find_all('div')[2].find('strong').get_text().strip()
-
-            response2 = requests.get(offer_url)
-            soup2 = BeautifulSoup(response2.content, 'html.parser')
-            offer_shop_code = soup2.find('div', {'class': 'product-desc'}).get_text().strip().split('\n')[3]
-
-            offer_description = soup2.find('div', {'class': 'description'}) \
-                .find('div', {'class': 'tab-content'}).find('pre').get_text().strip()
-
-            print(offer_name)
-            print(brand)
-            print()
-            print()
-
-            # insert_script = 'INSERT INTO phone_offers (offer_shop, brand, offer_name , price, image_url, offer_url,' \
-            #                 'offer_shop_code, offer_description, last_updated, is_validated)' \
-            #                 ' VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s);'
-            # insert_value = (offer_shop, brand, offer_name, price, image_url, offer_url,
-            #                 offer_shop_code, offer_description, last_updated, is_validated)
-            # cur.execute(insert_script, insert_value)
-            # db_connection.commit()
-    else:
-        driver1.implicitly_wait(5)
-        scrape_function(driver1, i)
-
-
-for i in range(1, 19):
-    anhoch_url = "https://www.anhoch.com/category/3017/smartfoni-i-mobilni-tel#page/"+str(i)
-    # print(anhoch_url)
-
-    # selenium is used because of the dynamic content of the page
-    driver1 = webdriver.Safari(executable_path='/usr/bin/safaridriver')
-    driver1.get(anhoch_url)
-
-    scrape_function(driver1, i)
-    # closing the driver so the safari instance can pair with another webdriver session
-    driver1.close()
-
-
-cur.close()
-db_connection.close()
Index: phonelux_scrappers/scrappers/handy_scrapper.py
===================================================================
--- phonelux_scrappers/scrappers/handy_scrapper.py	(revision b68ae8d3cc34d054d169fb34943b9fcd77bff7c2)
+++ phonelux_scrappers/scrappers/handy_scrapper.py	(revision ffd50db1e5e2b9839ba7546d8ca44b600150bd71)
@@ -1,2 +1,3 @@
+import json
 import unicodedata
 from datetime import datetime
@@ -9,20 +10,31 @@
 import sys
 
+from classes.phoneoffer import PhoneOffer
+
 file_path = 'outputfile.txt'
 sys.stdout = open(file_path, "w")
 
-# Call to read the configuration file and connect to database
-cinfo = config_read.get_databaseconfig("../postgresdb.config")
-db_connection = psycopg2.connect(
-    database=cinfo[0],
-    host=cinfo[1],
-    user=cinfo[2],
-    password=cinfo[3]
-)
-cur = db_connection.cursor()
 
 offer_shop = "Handy"  # offer shop
 last_updated = datetime.now().date()
 is_validated = False
+
+# Handy phone offers that are already in database
+offers = json.loads(unicodedata.normalize('NFKD', requests.get('http://localhost:8080/phoneoffer/shop/handy').text))
+
+database_offers = []
+
+for offer in offers:
+    phoneOffer = PhoneOffer(offer['id'], offer['offer_shop'], offer['offer_name'], offer['price'],
+                            offer['ram_memory'],
+                            offer['rom_memory'], offer['color'], offer['front_camera'], offer['back_camera'],
+                            offer['chipset'], offer['battery'], offer['operating_system'], offer['cpu'],
+                            offer['image_url'],
+                            offer['offer_url'], offer['last_updated'], offer['is_validated'],
+                            offer['offer_description'],
+                            offer['offer_shop_code'])
+    database_offers.append(phoneOffer)
+
+new_offers = []
 
 handy_url = 'https://www.handy.mk/telefoni?page=6'
@@ -44,9 +56,19 @@
     soup2 = BeautifulSoup(response2.text, 'html.parser')
 
+    back_camera = None
+    operating_system = None
+    chipset = None
+    battery = None
+    ram_memory = None
+    rom_memory = None
+    cpu = None
+    front_camera = None
+    offer_shop_code = None
+    color = None
+    image_url = None
+
     color_section = soup2.find('section', {'data-hook': 'product-colors-title-section'})
-
-    color = None
     if color_section is not None:
-        temp_colors = color_section.find('fieldset', {'class': 'ColorPickerbase3563640754__container'})\
+        temp_colors = color_section.find('fieldset', {'class': 'ColorPickerbase3548966286__container'})\
             .find_all('input', {'type': 'radio'})
         colors_list = []
@@ -67,12 +89,52 @@
     offer_description = '\n'.join(specifications)
 
-    insert_script = 'INSERT INTO phone_offers (offer_shop, brand, offer_name , price, offer_url, ' \
-                    'offer_description, last_updated, is_validated)' \
-                            ' VALUES (%s, %s, %s, %s, %s, %s, %s, %s);'
-    insert_value = (offer_shop, brand, offer_name, price, offer_url, offer_description,
-                            last_updated, is_validated)
-    cur.execute(insert_script, insert_value)
-    db_connection.commit()
+    new_offers.append(PhoneOffer(offer_shop, offer_name, price, ram_memory, rom_memory,
+                                 color, front_camera, back_camera, chipset, battery, operating_system, cpu,
+                                 image_url,
+                                 offer_url, last_updated, is_validated, offer_description, offer_shop_code))
 
-cur.close()
-db_connection.close()
+for new_offer in new_offers:
+    flag = False
+    flag_price = False
+    offer_id = None
+
+    for old_offer in database_offers:
+
+        if new_offer.offer_name == old_offer.offer_name:
+            flag = True
+            if new_offer.price != old_offer.price:
+                flag_price = True
+                offer_id = old_offer.offer_id
+
+    if flag:
+        # print('ALREADY IN DATABASE')
+        # print(new_offer)
+        # if it's already in database, check PRICE and if it's changed, change it !!!!!!
+        if flag_price:
+            print('PRICE CHANGED!')  # CHANGE PRICE
+            print('offer id: ' + str(offer_id))
+            headers = {'Content-type': 'application/json'}
+            requests.put('http://localhost:8080/phoneoffer/' + str(offer_id) + '/changeprice/' + str(new_offer.price),
+                         headers=headers)
+    else:
+        print('ADDED')  # ADD OFFER
+        print(new_offer)
+        headers = {'Content-type': 'application/json'}
+        requests.post('http://localhost:8080/phoneoffer/addoffer',
+                      headers=headers, data=json.dumps(new_offer.__dict__, default=str))
+
+print('------------------------------------')
+
+for old_offer in database_offers:
+    flag = False
+    for new_offer in new_offers:
+        if old_offer.offer_name == new_offer.offer_name:
+            flag = True
+
+    if not flag:
+        print('OFFER DELETED')
+        print(old_offer)
+        # DELETE OFFER
+        requests.delete('http://localhost:8080/phoneoffer/deleteoffer/' + str(old_offer.offer_id))
+
+
Index: phonelux_scrappers/scrappers/ledikom_scrapper.py
===================================================================
--- phonelux_scrappers/scrappers/ledikom_scrapper.py	(revision b68ae8d3cc34d054d169fb34943b9fcd77bff7c2)
+++ phonelux_scrappers/scrappers/ledikom_scrapper.py	(revision ffd50db1e5e2b9839ba7546d8ca44b600150bd71)
@@ -1,5 +1,5 @@
+import json
 import unicodedata
 from datetime import datetime
-
 import psycopg2
 import config_read
@@ -10,20 +10,31 @@
 import sys
 
+from classes.phoneoffer import PhoneOffer
+
 file_path = 'outputfile.txt'
 sys.stdout = open(file_path, "w")
-
-# Call to read the configuration file and connect to database
-cinfo = config_read.get_databaseconfig("../postgresdb.config")
-db_connection = psycopg2.connect(
-    database=cinfo[0],
-    host=cinfo[1],
-    user=cinfo[2],
-    password=cinfo[3]
-)
-cur = db_connection.cursor()
 
 offer_shop = "Ledikom"  # offer shop
 last_updated = datetime.now().date()
 is_validated = False
+
+# Ledikom phone offers that are already in database
+
+offers = json.loads(unicodedata.normalize('NFKD', requests.get('http://localhost:8080/phoneoffer/shop/ledikom').text))
+
+database_offers = []
+
+for offer in offers:
+    phoneOffer = PhoneOffer(offer['id'], offer['offer_shop'], offer['offer_name'], offer['price'],
+                            offer['ram_memory'],
+                            offer['rom_memory'], offer['color'], offer['front_camera'], offer['back_camera'],
+                            offer['chipset'], offer['battery'], offer['operating_system'], offer['cpu'],
+                            offer['image_url'],
+                            offer['offer_url'], offer['last_updated'], offer['is_validated'],
+                            offer['offer_description'],
+                            offer['offer_shop_code'])
+    database_offers.append(phoneOffer)
+
+new_offers = []
 
 ledikom_phone_urls = [
@@ -65,5 +76,7 @@
         offer_name = ' '.join(temp_offer_name.split())
         brand = offer_name.split(' ')[0]
-        price = int(phone.find('span', {'class': 'price'}).get_text().replace('ден.', '').replace('.', '').strip())
+        price = int(phone.find('span', {'class': 'price'}).get_text().replace('ден.', '')
+                    .replace('ден', '')
+                    .replace('.', '').strip())
 
         driver1 = webdriver.Safari(executable_path='/usr/bin/safaridriver')
@@ -82,4 +95,12 @@
         rom_memory = None
         ram_memory = None
+        back_camera = None
+        operating_system = None
+        chipset = None
+        battery = None
+        cpu = None
+        front_camera = None
+        offer_shop_code = None
+        offer_description = None
 
         if len(specifications) != 0:
@@ -114,12 +135,50 @@
             color = temp
 
-        insert_script = 'INSERT INTO phone_offers (offer_shop, brand, offer_name, price, image_url, offer_url,' \
-                        'ram_memory, rom_memory, color, last_updated, is_validated)' \
-                        ' VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s);'
-        insert_value = (offer_shop, brand, offer_name, price, image_url, offer_url, ram_memory,
-                        rom_memory, color, last_updated, is_validated)
-        cur.execute(insert_script, insert_value)
-        db_connection.commit()
+        new_offers.append(PhoneOffer(offer_shop, offer_name, price, ram_memory, rom_memory,
+                                     color, front_camera, back_camera, chipset, battery, operating_system, cpu,
+                                     image_url,
+                                     offer_url, last_updated, is_validated, offer_description, offer_shop_code))
 
-cur.close()
-db_connection.close()
+for new_offer in new_offers:
+    flag = False
+    flag_price = False
+    offer_id = None
+
+    for old_offer in database_offers:
+
+        if new_offer.offer_name == old_offer.offer_name:
+            flag = True
+            if new_offer.price != old_offer.price:
+                flag_price = True
+                offer_id = old_offer.offer_id
+
+    if flag:
+        # print('ALREADY IN DATABASE')
+        # print(new_offer)
+        # if it's already in database, check PRICE and if it's changed, change it !!!!!!
+        if flag_price:
+            print('PRICE CHANGED!')  # CHANGE PRICE
+            print('offer id: ' + str(offer_id))
+            headers = {'Content-type': 'application/json'}
+            requests.put('http://localhost:8080/phoneoffer/' + str(offer_id) + '/changeprice/' + str(new_offer.price),
+                         headers=headers)
+    else:
+        print('ADDED')  # ADD OFFER
+        print(new_offer)
+        headers = {'Content-type': 'application/json'}
+        requests.post('http://localhost:8080/phoneoffer/addoffer',
+                      headers=headers, data=json.dumps(new_offer.__dict__, default=str))
+
+print('------------------------------------')
+
+for old_offer in database_offers:
+    flag = False
+    for new_offer in new_offers:
+        if old_offer.offer_name == new_offer.offer_name:
+            flag = True
+
+    if not flag:
+        print('OFFER DELETED')
+        print(old_offer)
+        # DELETE OFFER
+        requests.delete('http://localhost:8080/phoneoffer/deleteoffer/' + str(old_offer.offer_id))
Index: phonelux_scrappers/scrappers/mobelix_scrapper.py
===================================================================
--- phonelux_scrappers/scrappers/mobelix_scrapper.py	(revision b68ae8d3cc34d054d169fb34943b9fcd77bff7c2)
+++ phonelux_scrappers/scrappers/mobelix_scrapper.py	(revision ffd50db1e5e2b9839ba7546d8ca44b600150bd71)
@@ -1,2 +1,4 @@
+import json
+import sys
 import unicodedata
 from datetime import datetime
@@ -8,21 +10,31 @@
 
 # import sys
-#
-# file_path = 'outputfile.txt'
-# sys.stdout = open(file_path, "w")
+from classes.phoneoffer import PhoneOffer
 
-# Call to read the configuration file and connect to database
-cinfo = config_read.get_databaseconfig("../postgresdb.config")
-db_connection = psycopg2.connect(
-    database=cinfo[0],
-    host=cinfo[1],
-    user=cinfo[2],
-    password=cinfo[3]
-)
-cur = db_connection.cursor()
+file_path = 'outputfile.txt'
+sys.stdout = open(file_path, "w")
 
 offer_shop = "Mobelix"  # offer shop
 last_updated = datetime.now().date()
 is_validated = False
+
+# Mobelix phone offers that are already in database
+
+offers = json.loads(unicodedata.normalize('NFKD', requests.get('http://localhost:8080/phoneoffer/shop/mobelix').text))
+
+database_offers = []
+
+for offer in offers:
+    phoneOffer = PhoneOffer(offer['id'], offer['offer_shop'], offer['offer_name'], offer['price'],
+                            offer['ram_memory'],
+                            offer['rom_memory'], offer['color'], offer['front_camera'], offer['back_camera'],
+                            offer['chipset'], offer['battery'], offer['operating_system'], offer['cpu'],
+                            offer['image_url'],
+                            offer['offer_url'], offer['last_updated'], offer['is_validated'],
+                            offer['offer_description'],
+                            offer['offer_shop_code'])
+    database_offers.append(phoneOffer)
+
+new_offers = []
 
 for i in range(1, 17):
@@ -77,4 +89,6 @@
         back_camera = ''
         cpu = None
+        offer_shop_code = None
+        offer_description = None
 
         for table in tables:
@@ -120,14 +134,51 @@
             back_camera = None
 
-        insert_script = 'INSERT INTO phone_offers (offer_shop, brand, offer_name, price, image_url, offer_url,' \
-                        'ram_memory, rom_memory, battery, back_camera, front_camera, color, cpu, chipset, ' \
-                        'operating_system, last_updated, is_validated)' \
-                        ' VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s);'
-        insert_value = (offer_shop, brand, offer_name, price, image_url, offer_url, ram_memory, rom_memory,
-                        battery, back_camera, front_camera, color, cpu, chipset, operating_system,
-                        last_updated, is_validated)
-        cur.execute(insert_script, insert_value)
-        db_connection.commit()
+        new_offers.append(PhoneOffer(offer_shop, offer_name, price, ram_memory, rom_memory,
+                                     color, front_camera, back_camera, chipset, battery, operating_system, cpu,
+                                     image_url,
+                                     offer_url, last_updated, is_validated, offer_description, offer_shop_code))
 
-cur.close()
-db_connection.close()
+
+for new_offer in new_offers:
+    flag = False
+    flag_price = False
+    offer_id = None
+
+    for old_offer in database_offers:
+
+        if new_offer.offer_name == old_offer.offer_name:
+            flag = True
+            if new_offer.price != old_offer.price:
+                flag_price = True
+                offer_id = old_offer.offer_id
+
+    if flag:
+        # print('ALREADY IN DATABASE')
+        # print(new_offer)
+        # if it's already in database, check PRICE and if it's changed, change it !!!!!!
+        if flag_price:
+            print('PRICE CHANGED!')  # CHANGE PRICE
+            print('offer id: ' + str(offer_id))
+            headers = {'Content-type': 'application/json'}
+            requests.put('http://localhost:8080/phoneoffer/' + str(offer_id) + '/changeprice/' + str(new_offer.price),
+                         headers=headers)
+    else:
+        print('ADDED')  # ADD OFFER
+        print(new_offer)
+        headers = {'Content-type': 'application/json'}
+        requests.post('http://localhost:8080/phoneoffer/addoffer',
+                      headers=headers, data=json.dumps(new_offer.__dict__, default=str))
+
+print('------------------------------------')
+
+for old_offer in database_offers:
+    flag = False
+    for new_offer in new_offers:
+        if old_offer.offer_name == new_offer.offer_name:
+            flag = True
+
+    if not flag:
+        print('OFFER DELETED')
+        print(old_offer)
+        # DELETE OFFER
+        requests.delete('http://localhost:8080/phoneoffer/deleteoffer/' + str(old_offer.offer_id))
Index: phonelux_scrappers/scrappers/mobigo_scrapper.py
===================================================================
--- phonelux_scrappers/scrappers/mobigo_scrapper.py	(revision b68ae8d3cc34d054d169fb34943b9fcd77bff7c2)
+++ phonelux_scrappers/scrappers/mobigo_scrapper.py	(revision ffd50db1e5e2b9839ba7546d8ca44b600150bd71)
@@ -1,2 +1,4 @@
+import json
+import unicodedata
 from datetime import datetime
 
@@ -5,23 +7,35 @@
 from bs4 import BeautifulSoup
 import requests
+import sys
 
-# import sys
-#
-# file_path = 'outputfile.txt'
-# sys.stdout = open(file_path, "w")
+from classes.phoneoffer import PhoneOffer
 
-# Call to read the configuration file and connect to database
-cinfo = config_read.get_databaseconfig("../postgresdb.config")
-db_connection = psycopg2.connect(
-    database=cinfo[0],
-    host=cinfo[1],
-    user=cinfo[2],
-    password=cinfo[3]
-)
-cur = db_connection.cursor()
+file_path = 'outputfile.txt'
+sys.stdout = open(file_path, "w")
 
 offer_shop = "Mobi Go"  # offer shop
 last_updated = datetime.now().date()
 is_validated = False
+
+# Mobi Go phone offers that are already in database
+
+offers = json.loads(unicodedata.normalize('NFKD', requests.get('http://localhost:8080/phoneoffer/shop/mobigo').text))
+
+database_offers = []
+
+for offer in offers:
+    phoneOffer = PhoneOffer(offer['id'], offer['offer_shop'], offer['offer_name'], offer['price'],
+                            offer['ram_memory'],
+                            offer['rom_memory'], offer['color'], offer['front_camera'], offer['back_camera'],
+                            offer['chipset'], offer['battery'], offer['operating_system'], offer['cpu'],
+                            offer['image_url'],
+                            offer['offer_url'], offer['last_updated'], offer['is_validated'],
+                            offer['offer_description'],
+                            offer['offer_shop_code'])
+    database_offers.append(phoneOffer)
+
+new_offers = []
+
+
 for i in range(1, 6):
     mobigo_url = "https://mobigo.mk/page/" + str(i) + "/"
@@ -55,11 +69,15 @@
         specifications = soup2.find('table', {'id': 'singlet'}).find_all('tr')
 
-        ram_memory = ""
-        rom_memory = ""
-        battery = ""
-        back_camera = ""
-        front_camera = ""
-        chipset = ""
-        operating_system = ""
+        ram_memory = None
+        rom_memory = None
+        battery = None
+        back_camera = None
+        front_camera = None
+        chipset = None
+        operating_system = None
+        cpu = None
+        offer_shop_code = None
+        offer_description = None
+        color = None
 
         for specification in specifications:
@@ -111,12 +129,51 @@
                     battery = None
 
-        insert_script = 'INSERT INTO phone_offers (offer_shop, brand, offer_name, price, image_url, offer_url, ram_memory,' \
-                        ' rom_memory, battery, back_camera, front_camera, chipset, operating_system, last_updated, is_validated)' \
-                        ' VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s);'
-        insert_value = (offer_shop, brand, offer_name, price, image_url, offer_url, ram_memory,
-                        rom_memory, battery, back_camera, front_camera, chipset, operating_system, last_updated, is_validated)
-        cur.execute(insert_script, insert_value)
-        db_connection.commit()
+        new_offers.append(PhoneOffer(offer_shop, offer_name, price, ram_memory, rom_memory,
+                                     color, front_camera, back_camera, chipset, battery, operating_system, cpu,
+                                     image_url,
+                                     offer_url, last_updated, is_validated, offer_description, offer_shop_code))
 
-cur.close()
-db_connection.close()
+
+for new_offer in new_offers:
+    flag = False
+    flag_price = False
+    offer_id = None
+
+    for old_offer in database_offers:
+
+        if new_offer.offer_name == old_offer.offer_name:
+            flag = True
+            if new_offer.price != old_offer.price:
+                flag_price = True
+                offer_id = old_offer.offer_id
+
+    if flag:
+        print('ALREADY IN DATABASE')
+        print(new_offer)
+        # if it's already in database, check PRICE and if it's changed, change it !!!!!!
+        if flag_price:
+            print('PRICE CHANGED!')  # CHANGE PRICE
+            print('offer id: ' + str(offer_id))
+            headers = {'Content-type': 'application/json'}
+            requests.put('http://localhost:8080/phoneoffer/' + str(offer_id) + '/changeprice/' + str(new_offer.price),
+                         headers=headers)
+    else:
+        print('ADDED')  # ADD OFFER
+        print(new_offer)
+        headers = {'Content-type': 'application/json'}
+        requests.post('http://localhost:8080/phoneoffer/addoffer',
+                      headers=headers, data=json.dumps(new_offer.__dict__, default=str))
+
+print('------------------------------------')
+
+for old_offer in database_offers:
+    flag = False
+    for new_offer in new_offers:
+        if old_offer.offer_name == new_offer.offer_name:
+            flag = True
+
+    if not flag:
+        print('OFFER DELETED')
+        print(old_offer)
+        # DELETE OFFER
+        requests.delete('http://localhost:8080/phoneoffer/deleteoffer/' + str(old_offer.offer_id))
Index: phonelux_scrappers/scrappers/mobilezone_scrapper.py
===================================================================
--- phonelux_scrappers/scrappers/mobilezone_scrapper.py	(revision b68ae8d3cc34d054d169fb34943b9fcd77bff7c2)
+++ phonelux_scrappers/scrappers/mobilezone_scrapper.py	(revision ffd50db1e5e2b9839ba7546d8ca44b600150bd71)
@@ -1,2 +1,3 @@
+import json
 import unicodedata
 from datetime import datetime
@@ -6,23 +7,33 @@
 from selenium import webdriver
 import requests
+import sys
 
-import sys
+from classes.phoneoffer import PhoneOffer
 
 file_path = 'outputfile.txt'
 sys.stdout = open(file_path, "w")
 
-# Call to read the configuration file and connect to database
-cinfo = config_read.get_databaseconfig("../postgresdb.config")
-db_connection = psycopg2.connect(
-    database=cinfo[0],
-    host=cinfo[1],
-    user=cinfo[2],
-    password=cinfo[3]
-)
-cur = db_connection.cursor()
-
 offer_shop = "Mobile Zone"  # offer shop
 last_updated = datetime.now().date()
 is_validated = False
+
+# Mobile Zone phone offers that are already in database
+
+offers = json.loads(unicodedata.normalize('NFKD', requests.get('http://localhost:8080/phoneoffer/shop/mobilezone').text))
+
+database_offers = []
+
+for offer in offers:
+    phoneOffer = PhoneOffer(offer['id'], offer['offer_shop'], offer['offer_name'], offer['price'],
+                            offer['ram_memory'],
+                            offer['rom_memory'], offer['color'], offer['front_camera'], offer['back_camera'],
+                            offer['chipset'], offer['battery'], offer['operating_system'], offer['cpu'],
+                            offer['image_url'],
+                            offer['offer_url'], offer['last_updated'], offer['is_validated'],
+                            offer['offer_description'],
+                            offer['offer_shop_code'])
+    database_offers.append(phoneOffer)
+
+new_offers = []
 
 for i in range(1, 3):
@@ -54,6 +65,13 @@
             offer_name = brand + ' ' + offer_name
 
-        price = int(unicodedata.normalize('NFKD', phone.find('span', {'class': 'woocommerce-Price-amount amount'})
-                                          .find('bdi').get_text().replace(',', '').replace('ден', '').strip()))
+        price_tag = phone.find('span', {'class': 'woocommerce-Price-amount amount'})
+        price = None
+
+        if price_tag is not None:
+            price = int(unicodedata.normalize('NFKD', price_tag.find('bdi').get_text()
+                                          .replace(',', '')
+                                          .replace('ден', '').strip()))
+        else:
+            continue
 
         response2 = requests.get(offer_url)
@@ -65,4 +83,10 @@
         front_camera = None
         rom_memory = None
+        ram_memory = None
+        operating_system = None
+        cpu = None
+        chipset = None
+        offer_description = None
+        offer_shop_code = None
         battery = None
         color = None
@@ -84,14 +108,50 @@
                 color = specification.find('td').get_text().strip()
 
+        new_offers.append(PhoneOffer(offer_shop, offer_name, price, ram_memory, rom_memory,
+                                     color, front_camera, back_camera, chipset, battery, operating_system, cpu,
+                                     image_url,
+                                     offer_url, last_updated, is_validated, offer_description, offer_shop_code))
 
+for new_offer in new_offers:
+    flag = False
+    flag_price = False
+    offer_id = None
 
-        insert_script = 'INSERT INTO phone_offers (offer_shop, brand, offer_name , price, offer_url, image_url, ' \
-                        'rom_memory, battery, color, front_camera, back_camera, last_updated, is_validated)' \
-                                ' VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s);'
-        insert_value = (offer_shop, brand, offer_name, price, offer_url, image_url, rom_memory, battery, color,
-                        front_camera, back_camera, last_updated, is_validated)
-        cur.execute(insert_script, insert_value)
-        db_connection.commit()
+    for old_offer in database_offers:
 
-cur.close()
-db_connection.close()
+        if new_offer.offer_name == old_offer.offer_name:
+            flag = True
+            if new_offer.price != old_offer.price:
+                flag_price = True
+                offer_id = old_offer.offer_id
+
+    if flag:
+        # print('ALREADY IN DATABASE')
+        # print(new_offer)
+        # if it's already in database, check PRICE and if it's changed, change it !!!!!!
+        if flag_price:
+            print('PRICE CHANGED!')  # CHANGE PRICE
+            print('offer id: ' + str(offer_id))
+            headers = {'Content-type': 'application/json'}
+            requests.put('http://localhost:8080/phoneoffer/' + str(offer_id) + '/changeprice/' + str(new_offer.price),
+                         headers=headers)
+    else:
+        print('ADDED')  # ADD OFFER
+        print(new_offer)
+        headers = {'Content-type': 'application/json'}
+        requests.post('http://localhost:8080/phoneoffer/addoffer',
+                      headers=headers, data=json.dumps(new_offer.__dict__, default=str))
+
+print('------------------------------------')
+
+for old_offer in database_offers:
+    flag = False
+    for new_offer in new_offers:
+        if old_offer.offer_name == new_offer.offer_name:
+            flag = True
+
+    if not flag:
+        print('OFFER DELETED')
+        print(old_offer)
+        # DELETE OFFER
+        requests.delete('http://localhost:8080/phoneoffer/deleteoffer/' + str(old_offer.offer_id))
Index: phonelux_scrappers/scrappers/mobitech_scrapper.py
===================================================================
--- phonelux_scrappers/scrappers/mobitech_scrapper.py	(revision b68ae8d3cc34d054d169fb34943b9fcd77bff7c2)
+++ phonelux_scrappers/scrappers/mobitech_scrapper.py	(revision ffd50db1e5e2b9839ba7546d8ca44b600150bd71)
@@ -1,2 +1,4 @@
+import json
+import unicodedata
 from datetime import datetime
 
@@ -5,18 +7,11 @@
 from bs4 import BeautifulSoup
 import requests
+import sys
 
-# import sys
-# file_path = 'outputfile.txt'
-# sys.stdout = open(file_path, "w")
+from classes.phoneoffer import PhoneOffer
 
-# Call to read the configuration file and connect to database
-cinfo = config_read.get_databaseconfig("../postgresdb.config")
-db_connection = psycopg2.connect(
-    database=cinfo[0],
-    host=cinfo[1],
-    user=cinfo[2],
-    password=cinfo[3]
-)
-cur = db_connection.cursor()
+file_path = 'outputfile.txt'
+sys.stdout = open(file_path, "w")
+
 
 mobitech_url = "https://mobitech.mk/shop/"
@@ -29,5 +24,25 @@
 
 offer_shop = "Mobitech"  # offer shop
+last_updated = datetime.now().date()
 is_validated = False
+
+# Mobitech phone offers that are already in database
+
+offers = json.loads(unicodedata.normalize('NFKD', requests.get('http://localhost:8080/phoneoffer/shop/mobitech').text))
+
+database_offers = []
+
+for offer in offers:
+    phoneOffer = PhoneOffer(offer['id'], offer['offer_shop'], offer['offer_name'], offer['price'],
+                            offer['ram_memory'],
+                            offer['rom_memory'], offer['color'], offer['front_camera'], offer['back_camera'],
+                            offer['chipset'], offer['battery'], offer['operating_system'], offer['cpu'],
+                            offer['image_url'],
+                            offer['offer_url'], offer['last_updated'], offer['is_validated'],
+                            offer['offer_description'],
+                            offer['offer_shop_code'])
+    database_offers.append(phoneOffer)
+
+new_offers = []
 
 for phone in phones:
@@ -40,5 +55,4 @@
     temp_prices = phone.find('div', {'class': 'jet-woo-product-price'}).find_all('bdi')
     price = int(float(temp_prices[len(temp_prices) - 1].get_text().replace("ден", "").replace(",", "").strip())) # price
-    last_updated = datetime.now().date()  # offer last_updated date
 
     response2 = requests.get(offer_url)
@@ -47,9 +61,15 @@
     specifications = soup2.find_all('h2', {'class': 'elementor-heading-title elementor-size-default'})
 
-    ram_memory = ""
-    rom_memory = ""
-    battery = ""
-    back_camera = ""
-    operating_system = ""
+    ram_memory = None
+    rom_memory = None
+    battery = None
+    back_camera = None
+    front_camera = None
+    operating_system = None
+    chipset = None
+    color = None
+    offer_shop_code = None
+    cpu = None
+    offer_description = None
 
     for specification in specifications:
@@ -62,5 +82,6 @@
         # ram memory
         if specification.get_text().startswith("РАМ Меморија:"):
-            ram_memory = specification.get_text().split("РАМ Меморија:")[1].strip()
+            ram_memory = specification.get_text().split("РАМ Меморија:")[1].replace('RAM', '')\
+                .replace('Ram', '').strip()
             if ram_memory == "Нема" or ram_memory == "/":
                 ram_memory = None
@@ -84,12 +105,51 @@
                 battery = None
 
-    insert_script = 'INSERT INTO phone_offers (offer_shop, brand, offer_name, price, image_url, offer_url, ram_memory,' \
-                    ' rom_memory, battery, back_camera, last_updated, operating_system, is_validated)' \
-                    ' VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s);'
-    insert_value = (offer_shop, brand, offer_name, price, image_url, offer_url, ram_memory,
-                    rom_memory, battery, back_camera, last_updated, operating_system, is_validated)
-    cur.execute(insert_script, insert_value)
-    db_connection.commit()
+    new_offers.append(PhoneOffer(offer_shop, offer_name, price, ram_memory, rom_memory,
+                                 color, front_camera, back_camera, chipset, battery, operating_system, cpu,
+                                 image_url,
+                                 offer_url, last_updated, is_validated, offer_description, offer_shop_code))
 
-cur.close()
-db_connection.close()
+for new_offer in new_offers:
+    flag = False
+    flag_price = False
+    offer_id = None
+
+    for old_offer in database_offers:
+
+        if new_offer.offer_name == old_offer.offer_name:
+            flag = True
+            if new_offer.price != old_offer.price:
+                flag_price = True
+                offer_id = old_offer.offer_id
+
+    if flag:
+        print('ALREADY IN DATABASE')
+        print(new_offer)
+        # if it's already in database, check PRICE and if it's changed, change it !!!!!!
+        if flag_price:
+            print('PRICE CHANGED!')  # CHANGE PRICE
+            print('offer id: ' + str(offer_id))
+            headers = {'Content-type': 'application/json'}
+            requests.put('http://localhost:8080/phoneoffer/' + str(offer_id) + '/changeprice/' + str(new_offer.price),
+                         headers=headers)
+    else:
+        print('ADDED')  # ADD OFFER
+        print(new_offer)
+        headers = {'Content-type': 'application/json'}
+        requests.post('http://localhost:8080/phoneoffer/addoffer',
+                      headers=headers, data=json.dumps(new_offer.__dict__, default=str))
+
+print('------------------------------------')
+
+for old_offer in database_offers:
+    flag = False
+    for new_offer in new_offers:
+        if old_offer.offer_name == new_offer.offer_name:
+            flag = True
+
+    if not flag:
+        print('OFFER DELETED')
+        print(old_offer)
+        # DELETE OFFER
+        requests.delete('http://localhost:8080/phoneoffer/deleteoffer/' + str(old_offer.offer_id))
+
Index: phonelux_scrappers/scrappers/neptun_scrapper.py
===================================================================
--- phonelux_scrappers/scrappers/neptun_scrapper.py	(revision b68ae8d3cc34d054d169fb34943b9fcd77bff7c2)
+++ phonelux_scrappers/scrappers/neptun_scrapper.py	(revision ffd50db1e5e2b9839ba7546d8ca44b600150bd71)
@@ -1,2 +1,3 @@
+import json
 import unicodedata
 from datetime import datetime
@@ -9,16 +10,8 @@
 import sys
 
+from classes.phoneoffer import PhoneOffer
+
 file_path = 'outputfile.txt'
 sys.stdout = open(file_path, "w")
-
-# Call to read the configuration file and connect to database
-cinfo = config_read.get_databaseconfig("../postgresdb.config")
-db_connection = psycopg2.connect(
-    database=cinfo[0],
-    host=cinfo[1],
-    user=cinfo[2],
-    password=cinfo[3]
-)
-cur = db_connection.cursor()
 
 offer_shop = "Neptun"  # offer shop
@@ -26,6 +19,25 @@
 is_validated = False
 
+# Neptun phone offers that are already in database
+
+offers = json.loads(unicodedata.normalize('NFKD', requests.get('http://localhost:8080/phoneoffer/shop/neptun').text))
+
+database_offers = []
+
+for offer in offers:
+    phoneOffer = PhoneOffer(offer['id'], offer['offer_shop'], offer['offer_name'], offer['price'],
+                            offer['ram_memory'],
+                            offer['rom_memory'], offer['color'], offer['front_camera'], offer['back_camera'],
+                            offer['chipset'], offer['battery'], offer['operating_system'], offer['cpu'],
+                            offer['image_url'],
+                            offer['offer_url'], offer['last_updated'], offer['is_validated'],
+                            offer['offer_description'],
+                            offer['offer_shop_code'])
+    database_offers.append(phoneOffer)
+
+new_offers = []
+
 for i in range(1, 11):
-    neptun_url = 'https://www.neptun.mk/mobilni_telefoni.nspx?page='+str(i)
+    neptun_url = 'https://www.neptun.mk/mobilni_telefoni.nspx?page=' + str(i)
 
     # selenium is used because of the dynamic content of the page
@@ -72,4 +84,5 @@
         offer_description = specifications_table.get_text(separator='\n').strip()
 
+        back_camera = None
         operating_system = None
         chipset = None
@@ -78,4 +91,7 @@
         rom_memory = None
         cpu = None
+        front_camera = None
+        color = None
+
         for specification in specifications:
             if 'Батерија:' in specification:
@@ -105,14 +121,50 @@
                 operating_system = specification
 
-        insert_script = 'INSERT INTO phone_offers (offer_shop, brand, offer_name , price, image_url, offer_url,' \
-                        'offer_shop_code, operating_system, battery, chipset, cpu, ram_memory, rom_memory, ' \
-                        'offer_description, last_updated, is_validated)' \
-                        ' VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s);'
-        insert_value = (offer_shop, brand, offer_name, price, image_url, offer_url,
-                        offer_shop_code, operating_system, battery, chipset, cpu, ram_memory, rom_memory, offer_description,
-                        last_updated, is_validated)
-        cur.execute(insert_script, insert_value)
-        db_connection.commit()
+        new_offers.append(PhoneOffer(offer_shop, offer_name, price, ram_memory, rom_memory,
+                                     color, front_camera, back_camera, chipset, battery, operating_system, cpu,
+                                     image_url,
+                                     offer_url, last_updated, is_validated, offer_description, offer_shop_code))
 
-cur.close()
-db_connection.close()
+for new_offer in new_offers:
+    flag = False
+    flag_price = False
+    offer_id = None
+
+    for old_offer in database_offers:
+
+        if new_offer.offer_shop_code == old_offer.offer_shop_code:
+            flag = True
+            if new_offer.price != old_offer.price:
+                flag_price = True
+                offer_id = old_offer.offer_id
+
+    if flag:
+        # print('ALREADY IN DATABASE')
+        # print(new_offer)
+        # if it's already in database, check PRICE and if it's changed, change it !!!!!!
+        if flag_price:
+            print('PRICE CHANGED!')  # CHANGE PRICE
+            print('offer id: ' + str(offer_id))
+            headers = {'Content-type': 'application/json'}
+            requests.put('http://localhost:8080/phoneoffer/' + str(offer_id) + '/changeprice/' + str(new_offer.price),
+                         headers=headers)
+    else:
+        print('ADDED')  # ADD OFFER
+        print(new_offer)
+        headers = {'Content-type': 'application/json'}
+        requests.post('http://localhost:8080/phoneoffer/addoffer',
+                      headers=headers, data=json.dumps(new_offer.__dict__, default=str))
+
+print('------------------------------------')
+
+for old_offer in database_offers:
+    flag = False
+    for new_offer in new_offers:
+        if old_offer.offer_shop_code == new_offer.offer_shop_code:
+            flag = True
+
+    if not flag:
+        print('OFFER DELETED')
+        print(old_offer)
+        # DELETE OFFER
+        requests.delete('http://localhost:8080/phoneoffer/deleteoffer/' + str(old_offer.offer_id))
Index: phonelux_scrappers/scrappers/outputfile.txt
===================================================================
--- phonelux_scrappers/scrappers/outputfile.txt	(revision b68ae8d3cc34d054d169fb34943b9fcd77bff7c2)
+++ phonelux_scrappers/scrappers/outputfile.txt	(revision ffd50db1e5e2b9839ba7546d8ca44b600150bd71)
@@ -0,0 +1,9 @@
+ADDED
+{'offer_shop': 'Mobile Zone', 'offer_name': 'Apple iPhone 14 Pro', 'price': 95499, 'ram_memory': None, 'rom_memory': '128GB', 'color': 'Златна, Розева, Сива, Црна', 'front_camera': '12MP', 'back_camera': '48 Mp + 12 Mp + 12 Mp', 'chipset': None, 'battery': '3200mAh', 'operating_system': None, 'cpu': None, 'image_url': 'https://i0.wp.com/mobilezone.mk/wp-content/uploads/2022/09/14-pro-silver.png?resize=600%2C600&ssl=1', 'offer_url': 'https://mobilezone.mk/produkti/iphone-14-pro/', 'last_updated': datetime.date(2022, 10, 1), 'is_validated': False, 'offer_description': None, 'offer_shop_code': None}
+------------------------------------
+OFFER DELETED
+{'offer_id': 1179, 'offer_shop': 'Mobile Zone', 'offer_name': 'Samsung s20 FE', 'price': 24699, 'ram_memory': None, 'rom_memory': '128GB', 'color': 'Сина', 'front_camera': None, 'back_camera': None, 'chipset': None, 'battery': None, 'operating_system': None, 'cpu': None, 'image_url': 'https://i2.wp.com/mobilezone.mk/wp-content/uploads/2022/03/Samsung-Galaxy-S20-FE-blue.png?resize=512%2C600&ssl=1', 'offer_url': 'https://mobilezone.mk/produkti/samsung-s20-fe/', 'last_updated': '2022-07-29T22:00:00.000+00:00', 'is_validated': False, 'offer_description': None, 'offer_shop_code': None}
+OFFER DELETED
+{'offer_id': 1181, 'offer_shop': 'Mobile Zone', 'offer_name': 'Samsung Z Flip3 5G', 'price': 39999, 'ram_memory': None, 'rom_memory': '128GB', 'color': 'Црна', 'front_camera': None, 'back_camera': None, 'chipset': None, 'battery': None, 'operating_system': None, 'cpu': None, 'image_url': 'https://i2.wp.com/mobilezone.mk/wp-content/uploads/2022/03/11.png?resize=600%2C600&ssl=1', 'offer_url': 'https://mobilezone.mk/produkti/samsung-z-flip3-5g/', 'last_updated': '2022-07-29T22:00:00.000+00:00', 'is_validated': False, 'offer_description': None, 'offer_shop_code': None}
+OFFER DELETED
+{'offer_id': 1180, 'offer_shop': 'Mobile Zone', 'offer_name': 'Samsung S21 FE 5G', 'price': 30899, 'ram_memory': None, 'rom_memory': '128GB', 'color': 'Зелена, Црна', 'front_camera': None, 'back_camera': None, 'chipset': None, 'battery': None, 'operating_system': None, 'cpu': None, 'image_url': 'https://i1.wp.com/mobilezone.mk/wp-content/uploads/2022/03/5g.jpg?resize=600%2C600&ssl=1', 'offer_url': 'https://mobilezone.mk/produkti/samsung-s21-fe-5g/', 'last_updated': '2022-07-29T22:00:00.000+00:00', 'is_validated': False, 'offer_description': None, 'offer_shop_code': None}
Index: phonelux_scrappers/scrappers/setec_scrapper.py
===================================================================
--- phonelux_scrappers/scrappers/setec_scrapper.py	(revision b68ae8d3cc34d054d169fb34943b9fcd77bff7c2)
+++ phonelux_scrappers/scrappers/setec_scrapper.py	(revision ffd50db1e5e2b9839ba7546d8ca44b600150bd71)
@@ -1,24 +1,15 @@
+import json
 import unicodedata
 from datetime import datetime
-
 import psycopg2
 import config_read
 from bs4 import BeautifulSoup
 import requests
+import sys
 
-import sys
+from classes.phoneoffer import PhoneOffer
 
 file_path = 'outputfile.txt'
 sys.stdout = open(file_path, "w")
-
-# Call to read the configuration file and connect to database
-cinfo = config_read.get_databaseconfig("../postgresdb.config")
-db_connection = psycopg2.connect(
-    database=cinfo[0],
-    host=cinfo[1],
-    user=cinfo[2],
-    password=cinfo[3]
-)
-cur = db_connection.cursor()
 
 offer_shop = "Setec"  # offer shop
@@ -26,6 +17,25 @@
 is_validated = False
 
-for i in range(1, 7):
-    setec_url = 'https://setec.mk/index.php?route=product/category&path=10066_10067&page='+str(i)
+# Setec phone offers that are already in database
+
+offers = json.loads(unicodedata.normalize('NFKD', requests.get('http://localhost:8080/phoneoffer/shop/setec').text))
+
+database_offers = []
+
+for offer in offers:
+    phoneOffer = PhoneOffer(offer['id'], offer['offer_shop'], offer['offer_name'], offer['price'],
+                            offer['ram_memory'],
+                            offer['rom_memory'], offer['color'], offer['front_camera'], offer['back_camera'],
+                            offer['chipset'], offer['battery'], offer['operating_system'], offer['cpu'],
+                            offer['image_url'],
+                            offer['offer_url'], offer['last_updated'], offer['is_validated'],
+                            offer['offer_description'],
+                            offer['offer_shop_code'])
+    database_offers.append(phoneOffer)
+
+new_offers = []
+
+for i in range(1, 9):
+    setec_url = 'https://setec.mk/index.php?route=product/category&path=10066_10067&page=' + str(i)
 
     response1 = requests.get(setec_url)
@@ -41,4 +51,14 @@
         brand = offer_name.split(' ')[0]
 
+        back_camera = None
+        operating_system = None
+        chipset = None
+        battery = None
+        ram_memory = None
+        rom_memory = None
+        cpu = None
+        front_camera = None
+        color = None
+
         if 'Cable' in offer_name or 'AirTag' in offer_name:
             continue
@@ -49,7 +69,13 @@
         offer_shop_code = phone.find('div', {'class': 'right'}) \
             .find('div', {'class': 'shifra'}).get_text().replace('Шифра:', '').strip()
-        price = int(phone.find('div', {'class': 'right'}).find('div', {'class': 'price'}). \
-                    find('div', {'class': 'category-price-redovna'}).find('span', {'class': 'price-old-new'}) \
-                    .get_text().replace('Ден.', '').replace(',', '').strip())
+
+        price_tag = phone.find('div', {'class': 'right'}).find('div', {'class': 'price'}). \
+            find('div', {'class': 'category-price-redovna'}).find('span', {'class': 'price-old-new'})
+
+        if price_tag is None:
+            price_tag = phone.find('div', {'class': 'right'}).find('div', {'class': 'price'}). \
+                find('div', {'class': 'category-price-redovna'}).find('span', {'class': 'cena_za_kesh'})
+
+        price = int(price_tag.get_text().replace('Ден.', '').replace(',', '').strip())
 
         response2 = requests.get(offer_url)
@@ -58,12 +84,50 @@
         offer_description = soup2.find('div', {'id': 'tab-description'}).get_text(separator='\n')
 
-        insert_script = 'INSERT INTO phone_offers (offer_shop, brand, offer_name , price, image_url, offer_url,' \
-                        'offer_shop_code, offer_description, last_updated, is_validated)' \
-                        ' VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s);'
-        insert_value = (offer_shop, brand, offer_name, price, image_url, offer_url,
-                        offer_shop_code, offer_description, last_updated, is_validated)
-        cur.execute(insert_script, insert_value)
-        db_connection.commit()
+        new_offers.append(PhoneOffer(offer_shop, offer_name, price, ram_memory, rom_memory,
+                                     color, front_camera, back_camera, chipset, battery, operating_system, cpu,
+                                     image_url,
+                                     offer_url, last_updated, is_validated, offer_description, offer_shop_code))
 
-cur.close()
-db_connection.close()
+for new_offer in new_offers:
+    flag = False
+    flag_price = False
+    offer_id = None
+
+    for old_offer in database_offers:
+
+        if new_offer.offer_shop_code == old_offer.offer_shop_code:
+            flag = True
+            if new_offer.price != old_offer.price:
+                flag_price = True
+                offer_id = old_offer.offer_id
+
+    if flag:
+        # print('ALREADY IN DATABASE')
+        # print(new_offer)
+        # if it's already in database, check PRICE and if it's changed, change it !!!!!!
+        if flag_price:
+            print('PRICE CHANGED!')  # CHANGE PRICE
+            print('offer id: ' + str(offer_id))
+            headers = {'Content-type': 'application/json'}
+            requests.put('http://localhost:8080/phoneoffer/' + str(offer_id) + '/changeprice/' + str(new_offer.price),
+                         headers=headers)
+    else:
+        print('ADDED')  # ADD OFFER
+        print(new_offer)
+        headers = {'Content-type': 'application/json'}
+        requests.post('http://localhost:8080/phoneoffer/addoffer',
+                      headers=headers, data=json.dumps(new_offer.__dict__, default=str))
+
+print('------------------------------------')
+
+for old_offer in database_offers:
+    flag = False
+    for new_offer in new_offers:
+        if old_offer.offer_shop_code == new_offer.offer_shop_code:
+            flag = True
+
+    if not flag:
+        print('OFFER DELETED')
+        print(old_offer)
+        # DELETE OFFER
+        requests.delete('http://localhost:8080/phoneoffer/deleteoffer/' + str(old_offer.offer_id))
Index: phonelux_scrappers/scrappers/tehnomarket_scrapper.py
===================================================================
--- phonelux_scrappers/scrappers/tehnomarket_scrapper.py	(revision b68ae8d3cc34d054d169fb34943b9fcd77bff7c2)
+++ phonelux_scrappers/scrappers/tehnomarket_scrapper.py	(revision ffd50db1e5e2b9839ba7546d8ca44b600150bd71)
@@ -1,2 +1,3 @@
+import json
 import unicodedata
 from datetime import datetime
@@ -6,22 +7,13 @@
 from selenium import webdriver
 import requests
+import sys
 
-import sys
+from classes.phoneoffer import PhoneOffer
 
 file_path = 'outputfile.txt'
 sys.stdout = open(file_path, "w")
 
-# Call to read the configuration file and connect to database
-cinfo = config_read.get_databaseconfig("../postgresdb.config")
-db_connection = psycopg2.connect(
-    database=cinfo[0],
-    host=cinfo[1],
-    user=cinfo[2],
-    password=cinfo[3]
-)
-cur = db_connection.cursor()
 
-
-def scrape_function(driver1, i):
+def scrape_function(driver1, i, new_offers):
     offer_shop = "Tehnomarket"  # offer shop
     last_updated = datetime.now().date()
@@ -59,26 +51,48 @@
             offer_shop_code = details[4].strip()
 
+            back_camera = None
+            operating_system = None
+            chipset = None
+            battery = None
+            ram_memory = None
+            rom_memory = None
+            cpu = None
+            front_camera = None
+            color = None
+
             specifications = []
             for info in soup2.find_all('span', {'class': 'info'}):
                 specifications.append(info.get_text())
 
-            print(brand)
-            print(offer_name)
-            print()
-            print()
-
             offer_description = '\n'.join(specifications)
 
-            insert_script = 'INSERT INTO phone_offers (offer_shop, brand, offer_name, price, image_url, offer_url,' \
-                            'offer_description, offer_shop_code, last_updated, is_validated)' \
-                            ' VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s);'
-            insert_value = (offer_shop, brand, offer_name, price, image_url, offer_url, offer_description,
-                            offer_shop_code, last_updated, is_validated)
-            cur.execute(insert_script, insert_value)
-            db_connection.commit()
+            new_offers.append(PhoneOffer(offer_shop, offer_name, price, ram_memory, rom_memory,
+                                         color, front_camera, back_camera, chipset, battery, operating_system, cpu,
+                                         image_url,
+                                         offer_url, last_updated, is_validated, offer_description, offer_shop_code))
     else:
         driver1.implicitly_wait(30)
-        scrape_function(driver1, i)
+        scrape_function(driver1, i, new_offers)
 
+
+# Tehnomarket phone offers that are already in database
+
+offers = json.loads(
+    unicodedata.normalize('NFKD', requests.get('http://localhost:8080/phoneoffer/shop/tehnomarket').text))
+
+database_offers = []
+
+for offer in offers:
+    phoneOffer = PhoneOffer(offer['id'], offer['offer_shop'], offer['offer_name'], offer['price'],
+                            offer['ram_memory'],
+                            offer['rom_memory'], offer['color'], offer['front_camera'], offer['back_camera'],
+                            offer['chipset'], offer['battery'], offer['operating_system'], offer['cpu'],
+                            offer['image_url'],
+                            offer['offer_url'], offer['last_updated'], offer['is_validated'],
+                            offer['offer_description'],
+                            offer['offer_shop_code'])
+    database_offers.append(phoneOffer)
+
+new_offers = []
 
 for i in range(1, 6):
@@ -90,8 +104,50 @@
     driver1.get(tehnomarket_url)
 
-    scrape_function(driver1, i)
+    scrape_function(driver1, i, new_offers)
+
     # closing the driver so the safari instance can pair with another webdriver session
     driver1.close()
 
-cur.close()
-db_connection.close()
+for new_offer in new_offers:
+    flag = False
+    flag_price = False
+    offer_id = None
+
+    for old_offer in database_offers:
+
+        if new_offer.offer_shop_code == old_offer.offer_shop_code:
+            flag = True
+            if new_offer.price != old_offer.price:
+                flag_price = True
+                offer_id = old_offer.offer_id
+
+    if flag:
+        # print('ALREADY IN DATABASE')
+        # print(new_offer)
+        # if it's already in database, check PRICE and if it's changed, change it !!!!!!
+        if flag_price:
+            print('PRICE CHANGED!')  # CHANGE PRICE
+            print('offer id: ' + str(offer_id))
+            headers = {'Content-type': 'application/json'}
+            requests.put('http://localhost:8080/phoneoffer/' + str(offer_id) + '/changeprice/' + str(new_offer.price),
+                         headers=headers)
+    else:
+        print('ADDED')  # ADD OFFER
+        print(new_offer)
+        headers = {'Content-type': 'application/json'}
+        requests.post('http://localhost:8080/phoneoffer/addoffer',
+                      headers=headers, data=json.dumps(new_offer.__dict__, default=str))
+
+print('------------------------------------')
+
+for old_offer in database_offers:
+    flag = False
+    for new_offer in new_offers:
+        if old_offer.offer_shop_code == new_offer.offer_shop_code:
+            flag = True
+
+    if not flag:
+        print('OFFER DELETED')
+        print(old_offer)
+        # DELETE OFFER
+        requests.delete('http://localhost:8080/phoneoffer/deleteoffer/' + str(old_offer.offer_id))
