Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow set_value() to set values not present in form #222

Closed
ethanbsmith opened this issue Jul 16, 2018 · 4 comments
Closed

Allow set_value() to set values not present in form #222

ethanbsmith opened this issue Jul 16, 2018 · 4 comments
Labels
feature a feature request or enhancement form 🧾

Comments

@ethanbsmith
Copy link

ethanbsmith commented Jul 16, 2018

I'm trying to download [the full] dynamically expanded [holdings] table using rvest, but am getting an Unknown field names error.

s <- html_session("http://innovatoretfs.com/etf/?ticker=ffty")
f <- html_form(s)[[1]]
#the following line fails:
f.new <- set_values(f, `__EVENTTARGET` = "ctl00$BodyPlaceHolder$ViewHoldingsLinkButton")

##subsequent lines are not tested##
doc <- submit_form(s, f.new)
tabs <- xml_find_all(doc, "//table")
holdings <- html_table(tabs, fill = T, trim = T)[[5]]

I'm not great with HTML/HTTP but from what i can chase through, it seems to me that to expand the table requires a postback of the form with this new field value set

after inspecting the set_values function, it seems that it only allows existing fields to be assigned values.

is there any way to add a new field and a submit button to a form with rvest?

@ethanbsmith

This comment has been minimized.

@hadley

This comment has been minimized.

@tidyverse tidyverse deleted a comment from ethanbsmith Mar 17, 2019
@hadley hadley added the feature a feature request or enhancement label Mar 17, 2019
@hadley hadley changed the title Please add support for new fields and buttons on a form Allow set_value() to set values not present in form Mar 17, 2019
@hadley
Copy link
Member

hadley commented Dec 15, 2020

Hmmm, the problem is that this is currently an error, presumably because I want to help avoid accidentally setting the wrong values. That seems reasonable to me, so I think this request is out of scope for rvest. (But I am currently reconsidering the whole flow of the form submission process so it's possible I might change my mind)

@hadley hadley closed this as completed Dec 15, 2020
@staropram
Copy link

staropram commented Mar 9, 2022

It would be great if one could add new fields to a form. I have a situation where the website I'm scraping from uses a progressive sequence of submits and the javascript adds the new field before submitting at each step so it isn't in the original form. If I could add to the form, it would work.

Perhaps something like html_form_add_field(form,"blah"=3)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement form 🧾
Projects
None yet
Development

No branches or pull requests

3 participants