summaryrefslogtreecommitdiff
path: root/app/deals/models.py
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2023-07-14 15:04:26 -0500
committerluxagraf <sng@luxagraf.net>2023-07-14 15:04:26 -0500
commit33a87ab2b62d4692c9e0450bccf203eafdd8cd80 (patch)
treea7933e366c2a70691c34210a10cccd81e3c77569 /app/deals/models.py
parent9dc6e678a57203f0bc5c08f4780069b7cabdb45a (diff)
posts: added notes for saving urls
Diffstat (limited to 'app/deals/models.py')
-rw-r--r--app/deals/models.py140
1 files changed, 130 insertions, 10 deletions
diff --git a/app/deals/models.py b/app/deals/models.py
index 0d58367..a4fd875 100644
--- a/app/deals/models.py
+++ b/app/deals/models.py
@@ -61,6 +61,41 @@ class Deal(models.Model):
return format_html("<a target='_blank' href='https://camelcamelcamel.com/product/%s'>Deal?</a>" % (self.asin))
admin_link.short_description = 'Link'
+
+
+class MyDeal(models.Model):
+ title = models.CharField(max_length=200, blank=True, null=True)
+ lookup_title = models.CharField(max_length=200, blank=True, null=True)
+ asin = models.CharField(max_length=200, blank=True, null=True)
+ brand = models.CharField(max_length=200, blank=True, null=True)
+ retailer = models.CharField(max_length=200, blank=True, null=True)
+ secondary_retailer = models.CharField(max_length=200, blank=True, null=True)
+ tertiary_retailer = models.CharField(max_length=200, blank=True, null=True)
+ url = models.CharField(max_length=200)
+ secondary_url = models.CharField(max_length=200, blank=True, null=True)
+ tertiary_url = models.CharField(max_length=200, blank=True, null=True)
+ body = models.TextField(null=True, blank=True)
+ blurb = models.TextField(null=True)
+
+ class Meta:
+ ordering = ('title',)
+
+ def __str__(self):
+ return self.title
+
+ def amazon_link(self):
+ return format_html('<a target="_blank" href="%s">%s</a>' % (self.url, self.asin))
+ admin_link.short_description = 'Link'
+
+ def search_wired(self):
+ term = "https://www.google.com/search?q=%s" % (str(self.lookup_title))
+ term = term+"+site%3Awired.com"
+ return format_html("<a target='_blank' href='%s'>wired search</a>" % (term))
+ admin_link.short_description = 'Link'
+
+ def search_ccc(self):
+ return format_html("<a target='_blank' href='https://camelcamelcamel.com/product/%s'>Deal?</a>" % (self.asin))
+ admin_link.short_description = 'Link'
"""
@@ -145,17 +180,16 @@ with open(path) as f:
_, created = Deal.objects.get_or_create(
print(row)
asin=row[0],
- cateogry=row[1],
- brand=row[2],
- title=row[3],
- prime_only=row[4],
- promo_type=row[5],
- deal_price= row[9],
- original_price = row[10],
- discount_percent=row[11],
- url=row[12],
+ cateogry="New",
+ brand=row[7],
+ title=row[18],
+ prime_only=row[19],
+ promo_type=row[21],
+ deal_price= row[29],
+ original_price = row[31],
+ discount_percent=row[32],
+ url=row[34],
)
- print(row[0], row[1], row[2], row[4],row[5],row[6],row[10],row[13],row[14])
title, prime_only, promo_type, deal_price, discount_percent, url)
@@ -174,3 +208,89 @@ with open(path) as f:
# creates a tuple of the new object or
# current object and a boolean of if it was created
"""
+
+"""
+
+parse airtable csv:
+
+import tldextract, csv
+path = ''
+
+with open(path) as f:
+ reader = csv.reader(f)
+ count = 0
+ for row in reader:
+ if count > 0:
+ domain = tldextract.extract(row[2])
+ retailer = domain.domain.capitalize()
+ d = '#### [%s](%s)\n\n+++button-group\n\n[%s](%s "%s"){: target="_blank"}\n\n+++\n\n%s\n\n' %(str(row[0]).strip(), row[2], retailer, row[2], retailer, row[4])
+ with open('out.txt', 'a') as the_file:
+ the_file.write(d)
+ print(d)
+ count = count+1
+
+
+import tldextract, csv
+path = ''
+
+with open(path) as f:
+ reader = csv.reader(f)
+ count = 0
+ for row in reader:
+ if count > 0:
+ domain = tldextract.extract(row[2])
+ retailer = domain.domain.capitalize()
+ title = str(row[0].strip())
+ try:
+ stitle = title.split('for')[0]
+ except:
+ stitle=title
+ try:
+ asin = str(row[2]).split("/dp/")[1]
+ except:
+ asin = ''
+ d, created = MyDeal.objects.get_or_create(
+ title = str(row[0].strip()),
+ lookup_title = stitle,
+ asin = asin,
+ retailer = retailer,
+ url = str(row[2].strip())
+ )
+ if not created:
+ d.body = row[4]
+ d.save()
+ count = count+1
+
+
+
+
++++button-group
+
+[Amazon]({{object.url}} "Amazon"){: target="_blank"}
+
++++
+"""
+
+"""
+asin = 3
+deal_type = 4
+name = 6
+url = 7
+deal price = 9
+price = 8
+percent_discount_str = 10
+prime only = 11
+
+
+
+
+from selenium import webdriver
+from selenium.webdriver.common.keys import Keys
+from selenium.webdriver.common.by import By
+
+driver = webdriver.Firefox()
+driver.get("http://www.python.org")
+
+
+
+"""