Skip to content

Instantly share code, notes, and snippets.

@patperu
Last active April 19, 2016 13:57
Show Gist options
  • Save patperu/4e808b60f866b50a1e8b6c8a3770c69d to your computer and use it in GitHub Desktop.
Save patperu/4e808b60f866b50a1e8b6c8a3770c69d to your computer and use it in GitHub Desktop.
refpal via curl at opencpu
# https://public.opencpu.org/ocpu/webhook

# https://github.com/patperu/refpal
curl -k https://patperu.ocpu.io/refpal/R/get_data/print

# function (url)
# {
  # x <- read_xml(url) %>% xml_nodes("SV") %>% html_attrs()
  # x <- data.frame(do.call("rbind", x), stringsAsFactors = FALSE)
  # x$TOTVOT <- as.numeric(x$TOTVOT)
  # x$ELETTORI <- as.numeric(x$ELETTORI)
  # x$pct_vot <- x$TOTVOT/x$ELETTORI * 100
  # x
# }
# <environment: namespace:refpal>

curl -k https://patperu.ocpu.io/refpal/R/get_data -d "url='http://referendum2016.comune.palermo.it/AFFLSEZ_1_82053_R1.xml'"
# no applicable method for 'html_nodes' applied to an object of class "c('xml_document', 'xml_node')"

# In call:
# UseMethod("html_nodes")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment