1
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)}

我试图安排它从现在开始每分钟运行 62 秒。任务名称创建成功,但未发送电子邮件。但是,当上面的脚本单独运行时,它会发送一封电子邮件。我哪里错了?我的 taskscheduleR 代码是:

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"))
4

0 回答 0