Sending the Email
Service Request: send_email
send_emailfrom datetime import datetime stories = [sr.response.payload for sr in get_story_by_id] stories.sort(key=lambda story: story.score, reverse=True) query_ct = 500 if not input.payload.limitQuery else input.payload.limitQuery email_limit = 50 if not input.payload.limitEmail else input.payload.limitEmail with open_glyuefile("email_body.txt", "w") as file: file.write(f"Here are the top {email_limit} of the latest {query_ct} articles from Hacker news:\n\n") for story in stories[:email_limit]: time = datetime.fromtimestamp(story.time).strftime("%m/%d/%Y, %H:%M") file.writelines([ f"{story.title}\n", f"{story.url}\n", f"Posted by [{story.by}] on {time} ({story.score} points, {story.descendants} comments)\n", f"Discussion: https://news.ycombinator.com/item?id={story.id}\n\n" ])
Field Mappings for SR: send_email
send_emailLast updated
Was this helpful?