Spaces:
Runtime error
Runtime error
Commit ·
eb15014
1
Parent(s): e1d0a45
Update UltraScraper.py
Browse files- UltraScraper.py +7 -0
UltraScraper.py
CHANGED
|
@@ -139,6 +139,13 @@ class UltaScraper:
|
|
| 139 |
user="mumer113141",
|
| 140 |
password="SFBtp4xnPeA2")
|
| 141 |
cur = conn.cursor()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
cur.execute(
|
| 143 |
"INSERT INTO scraper_product (title, product_id, ingredients, url, store_name, date_created) VALUES (%s, %s, %s, %s, %s, %s)",
|
| 144 |
(product['title'], product['product_id'],
|
|
|
|
| 139 |
user="mumer113141",
|
| 140 |
password="SFBtp4xnPeA2")
|
| 141 |
cur = conn.cursor()
|
| 142 |
+
# check if the product is already in the database
|
| 143 |
+
cur.execute(
|
| 144 |
+
"SELECT product_id FROM scraper_product WHERE product_id = %s",
|
| 145 |
+
(product['product_id'], ))
|
| 146 |
+
if cur.fetchone():
|
| 147 |
+
return False
|
| 148 |
+
|
| 149 |
cur.execute(
|
| 150 |
"INSERT INTO scraper_product (title, product_id, ingredients, url, store_name, date_created) VALUES (%s, %s, %s, %s, %s, %s)",
|
| 151 |
(product['title'], product['product_id'],
|