Once you've extracted a form from a page with html_form() use form_set() to modify its values and form_submit() to submit it.

form_set(form, ...)

form_submit(form, session, submit = NULL, ...)

Arguments

form

An html_form().

...

<dynamic-dots> Name-value pairs giving fields to modify.

Provide a character vector to set multiple checkboxes in a set or select multiple values from a multi-select.

session

An html_session().

submit

Which button should be used?

  • NULL, the default, uses the first.

  • A string selects a button by its name.

  • A number selects a button based on it relative position.

Value

set_values() returns an updated form object; submit_form() returns the parsed HTML response (or an error if the HTTP request fails).

rvest 1.0.0

Deprecated lifecycle

In rvest 1.0.0, set_values() was deprecated in favor of form_set() and submit_form() in favor of form_submit(). Note that the argument order of form_submit() is different in order to facilitate use in a pipe

Examples

session <- html_session("http://www.google.com") search <- html_form(session)[[1]] if (FALSE) { search %>% set_values(q = "My little pony", hl = "fr") %>% submit_form(session) } # If you have a list of values, use !!! vals <- list(q = "web scraping", hl = "en") search %>% set_values(!!!vals)
#> Warning: `set_values()` is deprecated as of rvest 1.0.0. #> Please use `form_set()` instead. #> This warning is displayed once every 8 hours. #> Call `lifecycle::last_warnings()` to see where this warning was generated.
#> Warning: Setting value of hidden field 'hl'.
#> <form> 'f' (GET /search) #> <field> (hidden) ie: ISO-8859-1 #> <field> (hidden) hl: en #> <field> (hidden) source: hp #> <field> (hidden) biw: #> <field> (hidden) bih: #> <field> (text) q: web scraping #> <field> (submit) btnG: Google Search #> <field> (submit) btnI: I'm Feeling Lucky #> <field> (hidden) iflsig: AINFCbYAAAAAX-DIL... #> <field> (hidden) gbv: 1