This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Web Scraping in R with encode method

Hello, I need to do a web-scraping of the webpage below. I need to submit the form with some specific values. After submitting the form, I need to import the data into the R (table of the link "View results as text file") in a data.frame. I tried to make the submission using the following code, but I did not get good results:

library(rvest)
library(httr)

POST(
  url = "http://tempest.wellesley.edu/~btjaden/TargetRNA2/advanced.html",
  encode = "form",
  body=list(
    `text` = "Pediococcus pentosaceus SL4",
    `sequence` = ">RyhB GCGATCAGGAAGACCCTCGCGGAGAACCTGAAAGCACGACATTGCTCACATTGCTTCCAGTATTACTTAGCCAGCCGGGTGCTGGCTTTT",
    `sRNA_subregions` = "on",
    `window` = "10",
    `before` = "10",
    `after` = "20",
    `seed` = "7",
    `interaction_region` = "20",
    `candidate_targets` = "",
    `mRNA_accessibility` = "",
    `sigle_target` = "",
    `pvalue`= "0.05",
    `max_interactions`="400"
  ),
  verbose()
) -> res
content(res, as="parsed")

Can someone help me? I would greatly appreciate it. Thanks

r web-scraping rvest

This looks like plain programming to me, rather than specific bioinformatics. As such it's more suitable for stackoverflow.

In addition to not being a bioinformatics question, the question is poorly formulated. What is the desired outcome ? What is the outcome produced by the code and why is it "not good" ?

1 answer

Check the docs of the rvest package. There's a submit_form() function that you can use with a set_values() function. Try something like:

url <- "http://tempest.wellesley.edu/~btjaden/TargetRNA2/advanced.html"
page <- html_session(url)    
form <- html_form(page)
form <- set_values(form, ...)
submit_form(page, form)

Log in to answer this question.