Skip to content

Instantly share code, notes, and snippets.

View cargurus-scraper.R
# data source: https://www.cargurus.com/Cars/price-trends/
library(tidyverse)
library(dplyr)
library(httr)
library(jsonlite)
library(broom)
library(lubridate)
library(scales)
View dbt-webshot.R
# import
library(webshot)
# set working directory
setwd("~/Downloads")
# extract as .pdf files
webshot("https://www.getdbt.com/analytics-engineering/start-here/", "dbt-1-start-here.pdf")
webshot("https://www.getdbt.com/what-is-analytics-engineering/", "dbt-2-what-is-analytics-engineering.pdf")
webshot("https://www.getdbt.com/analytics-engineering/why/", "dbt-3-why.pdf")
View twilio-demo-job.py
from twilio.rest import Client
try:
# run some code
message = 'Success!'
except:
# if it fails
message = 'Job failed!'
View twilio-demo.py
from twilio.rest import Client
# create client
account_sid = 'YOUR-ACCOUNT-SID'
auth_token = 'YOUR-AUTH-TOKEN'
client = Client(account_sid, auth_token)
# define message function
def sendMessage(body, from_, to):
message = client.messages.create(body = body, from_ = from_, to = to)
View web-scraping-ex-1-top-songs.R
library(rvest)
url = 'https://genius.com/#top-songs'
page = read_html(url)
top_songs = page %>% html_nodes('.qsIlk') %>% html_attr('href')
View zillow-pheonix.R
# set working directory
setwd("~/Projects/zillow")
# import libraries
library(tidyverse)
library(lubridate)
library(scales)
# define urls for import
url_1_bed = 'https://files.zillowstatic.com/research/public_v2/zhvi/Zip_zhvi_bdrmcnt_1_uc_sfrcondo_tier_0.33_0.67_sm_sa_mon.csv?t=1620762095'
View screenshot.py
# demo
import pyautogui
import winsound
frequency = 1500 # in Hertz
duration = 200 # 1000 ms == 1 second
winsound.Beep(frequency, duration)
path = r'C:\Users\erikgregorywebb\Documents\..\my_screenshot.png'
pyautogui.screenshot(path)
View realtor-ut.R
# set working directory
setwd("~/Projects/zillow")
# import libraries
library(tidyverse)
### REALTOR ###
# import realtor.com
# source: https://www.realtor.com/research/data/ (Inventory, Monthly)
View utah-zipcodes.csv
zipcode city county
84001 Altamont Duchesne
84002 Altonah Duchesne
84003 American Fork Utah
84004 Alpine Utah
84005 Eagle Mountain Utah
84006 Bingham Canyon Salt Lake
84007 Bluebell Duchesne
84008 Bonanza Uintah
84010 Bountiful Davis
View fec-campaign-finance-explorer.R
library(tidyverse)
library(rvest)
# define list of input
years = c('1996', '1998', '2000', '2002', '2004', '2006', '2008', '2010', '2012', '2014', '2016', '2018', '2020')
years_abbr = c('96', '98', '00', '02', '04','06', '08', '10', '12', '14', '16', '18', '20')
# loop over years, combine data
# source: https://www.fec.gov/data/browse-data/?tab=bulk-data
setwd("~/Projects/fec")