Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201894

Scrape Stocks' Historical Data in R for Pakistan Stock Exchange

$
0
0

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() %>%

Viewing all articles
Browse latest Browse all 201894

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>