Last active
December 1, 2019 16:40
-
-
Save ty-shaikh/104d49446d190ee43a4819eb049a1a7b to your computer and use it in GitHub Desktop.
Generate email markup for recent items.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} <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