Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9190427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:27:30+00:00 2026-06-17T20:27:30+00:00

How do I download through R the source code for a webpage that has

  • 0

How do I download through R the source code for a webpage that has tags that were created by JavaScript?

When I use the FireFox ‘Inspect Element’ function, tags are sometimes not shown in the HTML source file. In other words, information I need is in the JavaScript code. Is there a way to read this information into R?

Related question: How to view webpage source code using R?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:27:31+00:00Added an answer on June 17, 2026 at 8:27 pm

    You can use getURL from RCurl to get the HTTP response.

    library(RCurl)
    address <- "https://discussions.apple.com/thread/4356115?tstart=0"
    txt <- getURL(address)
    

    Now you can spit the string on the opening tag, then split that on the closing tag

    ss <- strsplit(txt, "<strong class=\"jive-thread-reply-message-correct-label\">")[[1]]
    strsplit(ss[2], "</strong>")[[1]][1]
    

    Which gives:

    [1] "This solved my question"
    

    It turns out that there is more than one of the div tag you wanted, and the above gets the wrong one. I don’t know how to do it purely in R, but I followed the post you referenced by VitoshKa and I got it to work.

    First, in Firefox go to Tools -> Add-ons. Search for and install mozrepl. Then, in Firefox click Tools -> MozRepl -> Start.

    Now, in R:

    mz <- socketConnection("localhost", "4242")
    writeLines("var w=window.open(\"https://discussions.apple.com/thread/4356115?tstart=0\")\n",mz)
    out <- readLines(mz) #empty the buffer
    writeLines("w.document.getElementsByTagName('html')[0].innerHTML\n", mz)
    out <- readLines(mz)
    
    (loc <- grep("jive-thread-reply-message-correct-label", out))
    #[1] 1150 2845
    

    Now, out is a vectorloc holds the positions of the strings that contain your tag. It appears twice. The first one is the one you’re interested in.

    out[loc[1]]
    

    You can extract the information from this the same way I showed above with strsplit, or with a regular expression and gsub


    You can close the window that opens with writeLines("w.window.close()", mz)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have rich client platform project. To ramble through source code I have download
I am trying to search the source code of a webpage, and download various
I have the following code to download a URL through a proxy: proxy_handler =
I was reading through the Tomcat source code, trying to figure out how the
Can I download source code of already deployed app if I've lost it's source
I have a webpage that offers dynamic downloading of mp3 files through mobile phones.
So I'm working through the code in this tutorial which has a small button
Im doing this project where i need to download files through a webservice (images,
I have developed a small download system in PHP, where files are downloaded through
I'm using the Android 2.1 API. I download from the web, through ksoap Protocol,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.