data <- read_html("https://www.amazon.in/Sony-Mirrorless-Real-time-Tracking-Vlogging/dp/B081JRT3X1/ref=sr_1_13?dchild=1&keywords=mirrorless+camera&qid=1614577648&sr=8-13")
price <- html_node(data, "#priceblock_ourprice")%>%
html_text()
price <- gsub('[^a-zA-Z0-9.]', '', price)%>%
as.numeric()
email_msg <- gm_mime()%>%
gm_to('****@gmail.com')%>%
gm_from("****@gmail.com")%>%
gm_subject("DSLR price update ")%>%
gm_text_body(paste("The price of Sony Alpha ILCE at ",
Sys.time(),
"is ",
paste0("Rupees ",price),
"on Amazon",
sep = "\n"))
if (price <= 59809){
gm_send_message(email_msg)}
I am trying to schedule it to run at every minute starting from 62 seconds from now. The task name is created successfully but no email is sent. However, when the script above is run separately it is sending an email. Where am i wrong? My taskscheduleR code is :
script <- "C:/Users/***/Documents/R/amazon_price_alerts.R"
library(taskscheduleR)
taskscheduler_create(taskname = "alert_email",
rscript = script,
schedule = "MINUTE",
starttime = format(Sys.time()+62, "%H:%M"))