Skip to content

Instantly share code, notes, and snippets.

@AO8
AO8 / it_enrollment_scraper2.py
Created July 18, 2018 18:05
A slightly different version of previous IT enrollment Python web scraper project. Includes GUI automation with pyautogui, scraping with BeautifulSoup, and sending gmail notifications with smtplib and MIMEText
# Standard Library
import smtplib
import webbrowser
from time import sleep
from datetime import datetime as dt
from urllib.request import urlopen
from email.mime.text import MIMEText
# Third-party
import pyautogui
from bs4 import BeautifulSoup
@AO8
AO8 / ask_zen_of_python.py
Last active August 6, 2018 21:28
Scrape a random piece of Zen from PEP 20 (Zen of Python) with BeautifulSoup.
# Python 3.6.4
import random
from time import sleep
import requests
from bs4 import BeautifulSoup
html = requests.get("https://www.python.org/dev/peps/pep-0020/")
soup = BeautifulSoup(html.text, "html.parser")
zen_of_python = soup.find("pre").get_text()
@AO8
AO8 / table_writer.py
Last active May 22, 2025 05:18
Convert an HTML table into a CSV file with Python and BeautifulSoup.
# Adapted from example in "Web Scraping with Python, 2nd Edition" by Ran Mitchell.
import csv
from urllib.request import urlopen
from bs4 import BeautifulSoup
html = urlopen("http://en.wikipedia.org/wiki/"
"Comparison_of_text_editors")
soup = BeautifulSoup(html, "html.parser")
table = soup.findAll("table", {"class":"wikitable"})[0]
@AO8
AO8 / story_scraper.py
Last active June 21, 2018 17:05
Using Python and BeautifulSoup, pull top stories from Medium on the topic of your choice.
# Get unlimited access to the smartest writers and biggest ideas by becoming
# a Medium member for just $5 / month. Visit https://medium.com/membership
import sys
import requests
from bs4 import BeautifulSoup
# Build elements of url to get
url = "https://medium.com/search?q=" # replace 'python' with the search keyword of your choice
@AO8
AO8 / crawler.py
Last active May 23, 2023 09:12
Crawl a website and gather all internal links with Python and BeautifulSoup.
# Adapted from example in Ch.3 of "Web Scraping With Python, Second Edition" by Ryan Mitchell
import re
import requests
from bs4 import BeautifulSoup
pages = set()
def get_links(page_url):
global pages
@AO8
AO8 / it_enrollment_scraper.py
Last active October 26, 2020 23:37
IT enrollment Python web scraper. Includes GUI automation with pyautogui, scraping with BeautifulSoup, and sending email notifications with smtplib.
# Standard Library
import smtplib
import webbrowser
from time import sleep
from datetime import datetime as dt
from urllib.request import urlopen
# Third-party
import pyautogui
from bs4 import BeautifulSoup
@AO8
AO8 / bacon_crawler.py
Last active May 25, 2018 18:23
Using Python and BeautifulSoup, decipher untold connections to Kevin Bacon with this mesmerizing Wikipedia crawler.
# Adapted from example in Ch.3 of "Web Scraping With Python, Second Edition" by Ryan Mitchell
# Make a tax-deductible donation to the Wikimedia Foundation at https://wikimediafoundation.org/wiki/Ways_to_Give
# Takeaway from this program: recursion is at the heart of web crawling. Crawlers retrieve page contents for a URL,
# examine that page for another URL, and retrieve that page, ad infinitum
import re
import random
import requests
from bs4 import BeautifulSoup
from datetime import datetime as dt
@AO8
AO8 / dow_visualizer.py
Last active June 21, 2018 19:14
Use Python, Requests, BeautifulSoup, CSV Writer, and MatPlotLib to scrape, write, and visualize a day on the stock market.
# From Python's Standard Library
from time import sleep
import datetime
import csv
# Third-party
import requests
import bs4
import matplotlib.pyplot as plt
times = []
@AO8
AO8 / csv_dow_tracker.py
Created March 8, 2018 18:08
Dow Jones tracker re-written with Requests package. Scrape and write data to a CSV file using Python 3 and Beautiful Soup.
import requests
import csv
import re
from bs4 import BeautifulSoup
from datetime import datetime as dt
dow_jones_page = "https://www.bloomberg.com/quote/INDU:IND"
html = requests.get(dow_jones_page).text
soup = BeautifulSoup(html, "html.parser")
@AO8
AO8 / cc_decrypt.py
Created March 3, 2018 23:57
Simple Caesar Cipher Python decryption function.
import string
from time import sleep
alphabet = string.ascii_lowercase # "abcdefghijklmnopqrstuvwxyz"
def decrypt():
print("Welcome to Caesar Cipher Decryption.\n")
encrypted_message = input("Enter the message you would like to decrypt: ").strip()
print()