Skip to content

Commit

Permalink
updates for november
Browse files Browse the repository at this point in the history
  • Loading branch information
maxhumber committed Nov 5, 2020
1 parent 69f880f commit 2cbbb57
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 20 deletions.
2 changes: 1 addition & 1 deletion notebooks/1-pesky.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.8.3"
}
},
"nbformat": 4,
Expand Down
22 changes: 11 additions & 11 deletions notebooks/2-scheduling.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -19,7 +19,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 11,
"metadata": {},
"outputs": [
{
Expand All @@ -36,7 +36,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 12,
"metadata": {},
"outputs": [
{
Expand All @@ -53,7 +53,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 19,
"metadata": {},
"outputs": [
{
Expand All @@ -70,7 +70,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -91,16 +91,16 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Orconomics'"
"''"
]
},
"execution_count": 6,
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -111,7 +111,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -137,7 +137,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -172,7 +172,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.8.3"
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions notebooks/3-multimedia.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
{
"data": {
"text/plain": [
"('media/orconomics.mp3', <http.client.HTTPMessage at 0x7f946e833d10>)"
"('media/orconomics.mp3', <http.client.HTTPMessage at 0x7fbb22fb8190>)"
]
},
"execution_count": 5,
Expand All @@ -82,7 +82,7 @@
{
"data": {
"text/plain": [
"('media/early.mp4', <http.client.HTTPMessage at 0x7f946df52910>)"
"('media/early.mp4', <http.client.HTTPMessage at 0x7fbb22fddb80>)"
]
},
"execution_count": 6,
Expand Down Expand Up @@ -126,7 +126,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.8.3"
}
},
"nbformat": 4,
Expand Down
15 changes: 10 additions & 5 deletions notebooks/4-ocr.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"from urllib.request import urlopen\n",
"from gazpacho import get, Soup\n",
"from PIL import Image # pip install pillow\n",
"import pytesseract # pip install pytesseract"
"import pytesseract # pip install pytesseract\n",
"# brew install tesseract"
]
},
{
Expand Down Expand Up @@ -103,12 +104,16 @@
"text": [
"\tPreface Samuel Zemurray, who led the United Fruit Company for roughly twenty-five years, from the early 1930s to the mid-’50s, was an emblematic figure of the American Century—those decades that saw the United States grow from a regional power into an empire. In Sam the Banana Man, as Zemurray was known to friends and enemies alike, the story of the age is collapsed to the scale of a single life: the ascent from humble origins, the promise and ambition, the sudden, dazzling, disorienting wealth, the corruption, brutality, propaganda, wars, and overreach—and the grinding late-day melancholy.\n",
"\t When he arrived in America in 1891 at age fourteen, Zemutray was tall, gangly, and penniless. When he died in the grandest house in New Orleans sixty-nine years later, he was among the richest, most powerful men in the world.\n",
"\tIn between, he worked as a fruit peddler, a banana hauler, a dockside hustler, and the owner of plantations on the Central American isthmus. He battled and conquered United Fruit, which was one of the first truly global corporations. United Fruit, in its day, was as ubiquitous as Google and as feared as Halliburton. More than a business, it was the spirit of the nation abroad, akin to the Dutch EastIndia Company, its policies backed by the threat of US.\n",
"\tIn between, he worked as a fruit peddler, a banana hauler, a dockside hustler, and the owner of plantations on the Central American isthmus. He battled and conquered United Fruit, which was one of the first truly global corporations. United Fruit, in its day, was as ubiquitous as Google and as feared as Halliburton. More than a business, it was the spirit of the nation abroad, akin to the Dutch East \f",
"\tIndia Company, its policies backed by the threat of US.\n",
"\tgunboats. As the president of United Fruit, Zemurray became the most important man in Central America—he could change the course of history with a phone call—a symbol of the best and worst of the United States: proof that America is the land of opportunity, but also a classic example of the Ugly American, the corporate pirate who treats foreign nations as the backdrop for his adventures. In South America, when people shouted “Yankee, go home!”\n",
"\tit was men like Samuel Zemurray they had in mind.\n",
"\t * OK OO I first learned about Zemurray as a sophomore at Tulane University. The Banana Man had been a generous donor to Tulane, and many of the buildings on campus are named for him or members of his family; the university president lives in the mansion on St. Charles Avenue where Zemutray spent some of his best years. I was transfixed by the story the moment I heard it in a seminar taught by Joseph Cohen, a relation to me in spirit alone. Unlike lectures in other classes, this was an epic, gaudy in character and incident, filled with mercenary soldiers and dirty wars, financial battles and the sort of political shenanigans familiar from the smoky back rooms of my hometown, Chicago.Zemutrray’s life is a parable of the American dream—not history as recorded in textbooks, but the authentic cask- strength version, a subterranean saga of kickbacks, overthrows, and secret deals: the world as it really works.\n",
"\t * OK OO I first learned about Zemurray as a sophomore at Tulane University. The Banana Man had been a generous donor to Tulane, and many of the buildings on campus are named for him or members of his family; the university president lives in the mansion on St. Charles Avenue where Zemutray spent some of his best years. I was transfixed by the story the moment I heard it in a seminar taught by Joseph Cohen, a relation to me in spirit alone. Unlike lectures in other classes, this was an epic, gaudy in character and incident, filled with mercenary soldiers and dirty wars, financial battles and the sort of political shenanigans familiar from the smoky back rooms of my hometown, Chicago.\n",
"\f",
"\tZemutrray’s life is a parable of the American dream—not history as recorded in textbooks, but the authentic cask- strength version, a subterranean saga of kickbacks, overthrows, and secret deals: the world as it really works.\n",
"\tThis story can shock and infuriate us, and it does. But I found it invigorating, too. It told me that the life of the nation was written not only by speech-making grandees in funny hats but also by street-corner boys, immigrant strivers, crazed and driven, some with one good idea, some with thousands, willing to go to the ends of the earth to make their vision real. It meant anyone could write a chapter in that book, be part of the story, vanish into the jungle and reemerge as a figure of lore. Of course, you would not make the mistakes Zemurray made. You would harm no one, and disturb nothing, and never pay off, and never kick back, and never compromise or lose your bearings. You would do it in a new sin-free way, win-win, which of course is also part of the American character, perhaps the most defining part: the notion that, if we were only given one more chance, we could finally get it right.\n",
"\t It’s what people mean when they speak of American exceptionalism: unlike the Europeans, we do not yet know you can’t be both powerful and righteous. So we set out again and again, convinced that this time we’ll avoid the mistakes of the previous generations. It’s this kind of confidence that gives a people the strength to rule abroad;\n"
"\t It’s what people mean when they speak of American exceptionalism: unlike the Europeans, we do not yet know you can’t be both powerful and righteous. So we set out again and again, convinced that this time we’ll avoid the mistakes of the previous generations. It’s this kind of confidence that gives a people the strength to rule abroad; \f",
"\n"
]
}
],
Expand All @@ -133,7 +138,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.8.3"
}
},
"nbformat": 4,
Expand Down
Binary file modified presentation.key
Binary file not shown.
Binary file modified presentation.pdf
Binary file not shown.
46 changes: 46 additions & 0 deletions scripts/bookbot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from email.message import EmailMessage
import os
import smtplib
from dotenv import find_dotenv, load_dotenv
from gazpacho import get, Soup

load_dotenv(".env")

sender = os.environ.get("GMAIL_USER")
password = os.environ.get("GMAIL_PASSWORD")
recipient = os.environ.get("RECIPIENT_EMAIL")

def parse(book):
name = book.find("h4").text
price = float(book.find("p").text[1:].split(" ")[0])
return name, price

def fetch_sale():
url = "https://scrape.world/books"
html = get(url)
soup = Soup(html)
books_raw = soup.find("div", {"class": "book-"})
books = [parse(book) for book in books_raw]
on_sale = [name for name, price in books if price == 0.99]
return "\n".join(on_sale)

def send_email(sender, password):
on_sale = fetch_sale()
if on_sale:
body = f"These books are on sale:\n{on_sale}\n\nBuy them now!"
else:
body = "Nothing on sale :("
msg = EmailMessage()
msg.set_content(body)
msg["Subject"] = "Books Bot"
msg["From"] = sender
msg["To"] = recipient
server = smtplib.SMTP_SSL("smtp.gmail.com", 465)
server.login(sender, password)
server.send_message(msg)
server.quit()


if __name__ == '__main__':
# https://support.google.com/accounts/answer/185833
send_email(sender, password)
3 changes: 3 additions & 0 deletions scripts/example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
GMAIL_USER=[email protected]
GMAIL_PASSWORD=pa$$word
RECIPIENT_EMAIL=[email protected]

0 comments on commit 2cbbb57

Please sign in to comment.