This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ggplot(moment, aes(x = minuteCount)) + | |
geom_histogram(binwidth = 10) + | |
labs(title="Distribution of Minute Counts") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://unboxed-analytics.shinyapps.io/the-potential-for-growth/ | |
# http://unboxed-analytics.com/life-hacking/fundamentals-of-investing/ | |
library(FinCal) | |
library(ggplot2) | |
library(tidyr) | |
library(shinythemes) | |
library(scales) | |
# Define UI for application that draws a histogram |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getListingLinks(link): | |
# Open the driver | |
driver = webdriver.Chrome(executable_path="/Users/erikgregorywebb/Downloads/chromedriver 2") | |
driver.get(link) | |
# Save the links | |
listing_links = [] | |
links = driver.find_elements_by_css_selector('.listing-item-link') | |
for link in links: | |
listing_links.append(str(link.get_attribute('href'))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getListingContent(listing_link): | |
# Open the driver | |
driver = webdriver.Chrome(executable_path="/Users/erikgregorywebb/Downloads/chromedriver 2") | |
driver.get(listing_link) | |
# Collect listing informtion | |
try: | |
title = driver.find_element_by_css_selector('.listingDetails-title') | |
location = driver.find_element_by_css_selector('.listingDetails-location') | |
price = driver.find_element_by_css_selector('.listingDetails-price') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from selenium.webdriver.common.keys import Keys | |
import time | |
import pandas as pd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getListings(url): | |
links = getListingLinks(url) | |
listings = [] | |
# Loop over each listing link | |
for i in range(0, 10): | |
time.sleep(3) | |
try: | |
listing = getListingContent(links[i]) | |
listings.append(listing) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def cleanLlistings(df): | |
# Split the location variable into location and days_online | |
df['location'], df['days_online'] = df['location'].str.split('|', 1).str | |
# Remove the dollar sign in price | |
df['price'] = df['price'].str.replace('$', '') | |
df['price'] = df['price'].str.replace(',', '') | |
# Convert from string to numeric | |
df['views'] = pd.to_numeric(df['views']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def main(url): | |
start_time = time.time() | |
# Process | |
raw_df = getListings(url) | |
df = cleanLlistings(raw_df) | |
# Export | |
df.to_csv("/Users/erikgregorywebb/Documents/Python/ksl-scrapper/listings.csv", sep = ',') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from selenium.webdriver.common.keys import Keys | |
import time | |
import pandas as pd | |
def getListingLinks(link): | |
# Open the driver | |
driver = webdriver.Chrome(executable_path="/Users/erikgregorywebb/Downloads/chromedriver 2") | |
driver.get(link) | |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
OlderNewer