Skip to content

Instantly share code, notes, and snippets.

@ty-shaikh
Last active December 1, 2019 16:40
Show Gist options
  • Save ty-shaikh/104d49446d190ee43a4819eb049a1a7b to your computer and use it in GitHub Desktop.
Save ty-shaikh/104d49446d190ee43a4819eb049a1a7b to your computer and use it in GitHub Desktop.
Generate email markup for recent items.
import pickle
def generate_markup(title, collection):
html = "<div style='text-align: center;'>"
heading = f'<p style="font-size: 1.5rem; font-weight: bold;">{title}&nbsp;<span style="font-size: 1rem;">({len(collection)} items)</span></p>'
item_group = ""
for item in collection:
title = item[0]
price = item[1]
link = "https://poshmark.com" + item[2]
img = item[3]
card_element = f'<a style="text-decoration: none;" href="{link}" target="_blank"><div style="box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2); width: 300px; margin: 0 auto;"><img src="{img}" style="max-width: 100%"><div style="padding: 2px 16px;"><p style="font-size: 1.3rem; font-weight: bold;">{title} ({price})</p></div></div></a></div><br>'
item_group += card_element
html = html + heading + item_group
return html
recent_items = pickle.load(open("naked_and_famous.p", "rb"))
email_markup = generate_markup("Naked and Famous Jeans", recent_items)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment