New email digest script generator
charliecurnin opened this issue · 2 comments
I'm not sure which repo is right for utils scripts like ones that generate the HTML for our email digest, and I can't create new repos in this organization, but lmk if there's a good spot for this.
The current email-digest-maker at https://thestanforddaily.github.io/email-newsletter-generator/ often breaks. I made a Python script that fulfills a similar function except you can run it locally, so you don't run into the "unresponsive page" bug. And it uses BeautifulSoup to pull headline, byline and a potential excerpt by parsing the HTML at article links.
The input to this script is just the ordered list of section names and urls to appear in a digest. For example, for the Aug. 23 digest,
FEATURED
https://www.stanforddaily.com/2020/08/17/toxic-work-culture-at-cantor-forces-staff-out-interventions-fall-short/
NEWS
https://www.stanforddaily.com/2020/08/19/stanford-to-provide-12-month-funding-for-all-ph-d-students/
https://www.stanforddaily.com/2020/08/20/basic-needs-coalition-fundraises-to-fill-institutional-resource-gaps-for-student-needs/
https://www.stanforddaily.com/2020/08/21/stanford-researchers-test-oral-covid-19-treatment-for-mild-cases/
OPINIONS
https://www.stanforddaily.com/2020/08/21/opinion-stanford-must-reform-bechtel-to-support-international-and-undocumented-students/
https://www.stanforddaily.com/2020/08/21/reverse-town-hall-open-letter-invitation-to-admin/
https://www.stanforddaily.com/2020/08/20/time-to-give-up-football/
SPORTS
https://www.stanforddaily.com/2020/08/20/sports-overtime-2/
https://www.stanforddaily.com/2020/08/14/sports-wrestling/
https://www.stanforddaily.com/2020/08/13/sports-upstream-battle-1/
ARTS & LIFE
https://www.stanforddaily.com/2020/08/19/black-fli-stanford-sophomores-weigh-in-on-whats-big-in-new-podcast/
https://www.stanforddaily.com/2020/08/18/an-exploration-of-foreign-films-kagemusha-takes-extravagance-to-a-new-level/
https://www.stanforddaily.com/2020/08/15/movies-to-watch-in-quarantine-extraction-the-master-four-weddings-and-a-funeral/
THE GRIND
https://www.stanforddaily.com/2020/08/21/social-media-treats-anti-asian-racism-as-normal-that-needs-to-change/
https://www.stanforddaily.com/2020/08/19/california-to-new-york-moving-in-the-middle-of-a-pandemic/
SATIRE
https://www.stanforddaily.com/2020/08/21/eight-socially-distanced-ways-to-tell-people-you-are-vegan/
https://www.stanforddaily.com/2020/08/19/a-new-and-deadly-pandemic-maskne/
Running the script with Python 3, like python3 make_digest.py digest-8-22.txt
, produces the HTML for the email digest. (The constant HTML header and footer snippets are currently stored in separate files, DIGEST_HEADER.txt
and DIGEST_FOOTER.txt
, that make_digest.py
reads.)
This is a rough draft and feedback is super welcome. Just wanted to put the script somewhere so I don't accidentally lose it.
I think being able to automatically pull the headline, byline and potential excerpt from the link is a helpful feature. (I say potential excerpt because the script just pulls the first paragraph of text from the article, so you should probably manually edit it.)
The script also has potential downsides too. It's not as convenient as a webpage you can visit. (E.g., you need to make sure people's computers are set up with Python 3, that they're familiar with terminal access.)
DIGEST_FOOTER.txt
DIGEST_HEADER.txt
make_digest.py.txt (Added .txt
extension because GitHub doesn't let you upload .py
as an attachment to an issue.)
Updated version that
- Does the special formatting for cartoons if you use the header
CARTOON OF THE DAY
in the input file, followed by the link - Adds commented-out ad spots after each section