2

I am working on Stocks' Analysis in R for Pakistan Stock Exchange. I am using "rvest" library and its tutorial at: https://github.com/hadley/rvest

Using this tutorial, I am trying to fetch the historical data into dataframes from this website: http://noormaier.net/kse-listed-companies-historical-prices-symbol-wise-2/

I have 2 questions:-

1) Using the above-mentioned tutorial, when I fetch the data using selectorgadget and the rest of the drill, the variable(list or the dataframe) in which the data is supposed to be stored is empty;

2) There are multiple tables on the above mentioned page which are accessed through a drop-down menu at the top of the page. When another value(Stock) is selected from the drop-down menu and submit button pressed, the relevant stock's data's table is loaded as the page gets reloaded but the Web Address of the page remains the same. The "Selector Part" obtained from the selectorgadget extension is also same for different stocks. If I need to access multiple Stock's data through the R Code, how will I differentiate between different stock's data.

Thanks in advance !

Here is the Code I have been using so far (with many alterations and experiments though):-

library(rvest)
web_link <- read_html("http://noormaier.net/kse-listed-companies-historical-prices//")

rating <- web_link %>% 
html_nodes(".DataWidgetTable:nth-child(10) td") %>%
html_text() %>%
Abdul Basit Khan
  • 646
  • 1
  • 6
  • 19
  • Please provide R code you come up with. – Aleksandr Mar 21 '17 at 08:51
  • I apologize for late reply. This is the code I came up with:- library(rvest) web_link <- read_html("http://noormaier.net/kse-listed-companies-historical-prices//") rating <- web_link %>% html_nodes(".DataWidgetTable:nth-child(10) td") %>% html_text() %>% – Abdul Basit Khan Mar 25 '17 at 12:01
  • I have included the code in the post above as well since I was unable to edit the above comment (after 5 minutes). It is just the basic code copied from the GitHub link of "hadley" above. The alterations according to the data I need from the website is also been included in the code. – Abdul Basit Khan Mar 25 '17 at 12:15

0 Answers0