From 17926056d5ca637bcc0a34e5a0ea4ef94b58a123 Mon Sep 17 00:00:00 2001 From: Maxime Wack Date: Tue, 1 Aug 2017 18:46:01 +0200 Subject: [PATCH] =?UTF-8?q?Corrected=20ao=C3=BBt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- feed_db.R | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/feed_db.R b/feed_db.R index f794027..a052a7e 100644 --- a/feed_db.R +++ b/feed_db.R @@ -7,6 +7,25 @@ library(stringr) annee <- 2017 +# Fetch celine and data ---- +celine <- GET(str_c("http://cngsante.fr/chiron", annee, "/celine/listing.html")) + +celine %>% + content %>% + html_node("tr:first-child") %>% + html_text -> +timestamp + +readRDS("prev_time.rds") -> prev_time + +if (timestamp == prev_time) +{ + q(save = "no") +} else +{ + saveRDS(timestamp, file = "prev_time.rds") +} + db <- dbConnect(SQLite(), "ecn.db") # Fetch previous state ---- @@ -18,14 +37,6 @@ db %>% filter(timestamp == max(timestamp)) -> current -# Fetch celine and data ---- -celine <- GET(str_c("http://cngsante.fr/chiron", annee, "/celine/listing.html")) - -celine %>% - content %>% - html_node("tr:first-child") %>% - html_text -> -timestamp timestamp %>% str_extract("\\d+h\\d+") %>% @@ -46,7 +57,7 @@ date %>% mois case_when(mois == "jul" ~ "07", mois == "sep" ~ "09", - mois %>% str_detect("^ao") ~ "08") -> + mois == "aoĆ»" ~ "08") -> mois timestamp <- str_c(annee, "-", mois, "-", jour, " ", heure)