Web Scraping in R with encode method
1
0
Entering edit mode
6.2 years ago
tatty_dk • 0

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 • 2.3k views
ADD COMMENT
1
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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" ?

ADD REPLY
1
Entering edit mode
6.2 years ago

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)
ADD COMMENT

Login before adding your answer.

Traffic: 1837 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6