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

handle multiple submit fields with same name #156

Closed
petermeissner opened this issue Jun 16, 2016 · 2 comments
Closed

handle multiple submit fields with same name #156

petermeissner opened this issue Jun 16, 2016 · 2 comments
Labels
feature a feature request or enhancement form 🧾

Comments

@petermeissner
Copy link

I had the following problem:

A form had multiple submit buttons all with the same name but different values. Because submit_form() only allows for selection of the submit by name I could not use it.

So it would be nice to be able - in addition to name

  • select submit buttons by index

or to be able to

  • manually control

what is used for the submit.

(originally submitted as pull request issue #146; for an real life example go here http://dipbt.bundestag.de/dip21.web/bt , click on Beratungsabäufe on the left side and have a look at the buttons)

@xguardi
Copy link

xguardi commented Apr 6, 2017

Any progress? This is a fairly common pattern when parsing paginated results (sometimes pagination links are different submits links with the same name but different valuers.

As in :

<form> 'formPag' (POST http://www.xxxx.xxx)
  <input hidden> 'type': 1
  <input submit> 'pag': 2
  <input submit> 'pag': 3
  <input submit> 'pag': 4

Cheers!

@xguardi
Copy link

xguardi commented Aug 1, 2017

Just in case somebody has this problem (several submit fields with the same name but different value). For example something like:

<div align="center" class="pagination-nums">
  <input type="submit" name="pag" value="1">
  <span class="pagination-act">2</span>
  <input type="submit" name="pag" value="3">
  <input type="submit" name="pag" value="4">
</div>

The way I finally solved it was by using Hadley's httr library (which rvest is build upon). It's lower level but actually very easy to use. For the case above it would be:

library(httr)
library(xml2)

# form fields 
fields <- list(
    'pag' = 2
)
# post request
r <- POST(url, 
          body = fields, 
          encode = 'form',
          user_agent('libcurl/7.43.0 r-curl/0.9.7 httr/1.2.1'))
# read as xml
r <- xml2::read_html(r)

Cheers!

@hadley hadley added feature a feature request or enhancement form 🧾 labels Mar 17, 2019
@hadley hadley closed this as completed in 121fc6c Dec 15, 2020
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