2

Is it possible to check a checkbox using the rvest set_values() function? In the example below the "form" object is a nested list that has the entry "fields" where "maillist" is a list with the entry "checked" that is NULL for unchecked, but how can it be checked using set_values?

library(rvest)
library(httr)
url <- "http://www.htmlcodetutorial.com/forms/_INPUT_TYPE_CHECKBOX.html"
session <- html_session(url)
form <- html_form(session)[[1]]
filled_form <- set_values(form, maillist = "checked")
results <- submit_form(session, filled_form)
content(results$response, "text")

An obvious workaround is that clicking the checkbox and submitting the form in a browser shows the value of maillist as "on", but this information might not always be known for other forms.

cannin
  • 1,402
  • 2
  • 17
  • 28

0 Answers0