knitr::opts_chunk$set( collapse = TRUE, comment = "##", fig.path = "README-" ) options(stringsAsFactors = FALSE)
albopop - Generate RSS feeds
The following functions are implemented:
ap_parse_page
: parse a pageap_build_rss
: build an rss feedap_build_msg
: build a message to send with Telegram and Twitterap_send_telegram
: send a message with Telegram noindex
meta tag (#90 in aborruso/albo-pop ) devtools::install_github("patperu/albopop")
options(width=160)
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:
JCityGov
Comune di Medesanomapweb
Comune di Loveresaga
Comune di Belluscostudiok
Comune di LuTo 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")
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:
blyurl
: The shortened URLmsg_Telegram
: The Telegram message, contains the title
, the blyurl
and the date
msg_Twitter
: The Twitter message, contains the title
(truncated to 100 characters), the blyurl
and the date
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)
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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.