Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ajdamico/f9ed24cff5c7b9ad29df4bdc9b5f3f91 to your computer and use it in GitHub Desktop.
Save ajdamico/f9ed24cff5c7b9ad29df4bdc9b5f3f91 to your computer and use it in GitHub Desktop.
library(rvest)
baseurl <- "https://washingtondc.craigslist.org/search/doc/jjj"
raw_query_list <-
lapply(
paste0( baseurl , "?s=" , seq( 0 , 1469 , 120 ) ) ,
xml2::read_html
)
raw_ads_list <- lapply( raw_query_list , html_nodes , "li.result-row" )
raw_ads_times <- lapply( raw_ads_list , html_node , 'time' )
datetimes <- lapply( raw_ads_times , html_attr , 'datetime' )
plot( as.Date( unlist( datetimes ) ) )
march_day <- as.numeric( format( as.Date( unlist( datetimes ) ) , "%d") )
hist(
march_day ,
main = "district of columbia job postings on craigslist.org" ,
xlab = 'day in march' ,
breaks = 1:31 ,
axes = FALSE
)
axis( side = 1 , at = seq( 1 , 31 ) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment