knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "##",
  fig.path = "README-"
)

options(stringsAsFactors = FALSE)

albopop - Generate RSS feeds

The following functions are implemented:

News

Installation

devtools::install_github("patperu/albopop")
options(width=160)

Usage

library("albopop")
library("rvest")

# current version
packageVersion("albopop")

The function ap_parse_page parse the content for different sites. The parameter site specify the type of input. Currently four providers are supported:

To parse the announcements for the Comune di Lu

res <- ap_parse_page(url = "http://albo.studiok.it/lu/albo", site = "studiok")
str(res)

The function ap_build_rss generates an RSS feed and writes a simple XML file in the local default directory feed. The input must contain at least three columns named Oggetto, Inizio and link. To write the file "Lu.xml":

ap_build_rss(res, 
             rss_title = "Comune di Lu", 
             rss_link  = "http://albo.studiok.it/lu/albo", 
             rss_file  = "Lu.xml")

Send notifications with Telegram and Twitter

Before sending notifications it is necessary to set the appropriate Tokens for bit.ly, Telegram and Twitter.

library(urlshorteneR)

bitly_token <- bitly_auth(key    = Sys.getenv("bitly_key"),
                          secret = Sys.getenv("bitly_secret"))

res <- data.frame(Comune = "Alseno.xml",
                  title  = "[53 / 2016] AVVISO DI AVVENUTO RILASCIO DI...",
                  pubDate = "2016-02-20",
                  link =  "http://albo.studiok.it/alseno/albo/dettaglio.php?id=MES00000000532016",
                  stringsAsFactors = FALSE)

res_msg <- ap_build_msg(res)
str(res_msg)
# 'data.frame': 1 obs. of  7 variables:
# $ Comune      : chr "Alseno.xml"
# $ title       : chr "[53 / 2016] AVVISO DI AVVENUTO RILASCIO DI..."
# $ pubDate     : chr "2016-02-20"
# $ link        : chr "http://albo.studiok.it/alseno/albo/dettaglio.php?id=MES00000000532016"
# $ blyurl      : chr "http://bit.ly/214xeQJ"
# $ msg_Telegram: chr "[53 / 2016] AVVISO DI AVVENUTO RILASCIO DI..., http://bit.ly/214xeQJ"
# $ msg_Twitter : chr "[53 / 2016] AVVISO DI AVVENUTO RILASCIO DI..., http://bit.ly/214xeQJ"

The function ap_build_msg adds three columns to the input:

ap_send_telegram(res_msg$msg_Telegram, "LU_TOKEN", "LU_CHAT_ID")

To send a notification with Twitter

library('twitteR')

setup_twitter_oauth(Sys.getenv("twitter_api_key"),
                    Sys.getenv("twitter_api_secret"),
                    Sys.getenv("twitter_access_token"),
                    Sys.getenv("twitter_access_token_secret"))

tweet(res_msg$msg_Twitter)

Meta

Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.



patperu/albopop documentation built on May 24, 2019, 8:21 p.m.