33 lines
751 B
R
33 lines
751 B
R
library("rvest")
|
|
library("dplyr")
|
|
library("ggmap")
|
|
library("stringr")
|
|
|
|
setwd("/home/francois/frigos_localisation")
|
|
|
|
url_page <-
|
|
"https://sauvetabouffe.org/boite-a-outils/repertoire-des-frigos-communautaires-du-quebec/"
|
|
selecteur_css <- "#tablepress-1"
|
|
|
|
html_page <- read_html(url_page)
|
|
|
|
frigo_table <-
|
|
html_page %>%
|
|
html_element(selecteur_css) %>%
|
|
html_table()
|
|
|
|
|
|
frigo_table2 <- frigo_table %>%
|
|
mutate(adr_propre = Adresse %>%
|
|
str_remove("\\(.*\\)$") %>%
|
|
str_trim())
|
|
|
|
source("register_google.R")
|
|
geo_frigo <- geocode(frigo_table2$adr_propre)
|
|
|
|
# Je patch celle qui n'a pas fonctionné
|
|
geo_frigo[4,] <- list(-67.4330588, 48.4657985)
|
|
|
|
frigo_table3 <- frigo_table2 %>% cbind(geo_frigo)
|
|
|
|
frigo_table3 %>% write.csv("frigo_table.csv")
|