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

submit_form produces <url> malformed error #52

Closed
alex23lemm opened this issue Dec 31, 2014 · 0 comments
Closed

submit_form produces <url> malformed error #52

alex23lemm opened this issue Dec 31, 2014 · 0 comments

Comments

@alex23lemm
Copy link

@alex23lemm alex23lemm commented Dec 31, 2014

I had the problem that submit_form always produced the following error when trying to enter a specific web page:

Submitting with 'login'
Error in function (type, msg, asError = TRUE)  : <url> malformed

A couple of days ago someone posted the same issue on SO and the answer given by MrFlick solved my issue:

Before submitting the form you have to explicitly set the url of the login form.

It seems that rvest has some problems when interpreting absolute URLs without the server name.

Reproducible example (The other one can be found on SO):

library(rvest)
library(magrittr)

my_url = "https://www.openair.com/index.pl"
openair <- html_session(my_url)

login <-  html_form(openair) %>%
  extract2(1) %>%
  set_values(
    account_nickname = "does_not_matter_here",
    user_nickname = "does_not_matter_here",
    password = "does_not_matter_here"
  )

openair %<>% submit_form(login)

The code above produces the described error. Taking a look at the beginning of login:

<form> 'login_page' (POST /index.pl)
<input hidden> '_form_has_changed': 0
...

However, adding login$url <- 'https://www.openair.com/index.pl' before submitting the form solves it.

In this case the start of login looks like this:

<form> 'login_page' (POST https://www.openair.com/index.pl)
<input hidden> '_form_has_changed': 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant