I am trying to pull some economic data from Investing.com. Here is a link to the non-farm payroll I am looking to pull. https://ca.investing.com/economic-calendar/nonfarm-payrolls-227

As you can see, once you click the show more button, more rows are loaded. I would like to scrape all the hidden data in the table.

If you inspect the page you can quite easily see the html tags associated with each row. I was wondering if there was an easy way to scrape the data without using R selenium.

enter image description here

Here is my current code that only returns the 6 rows initially showed when first entering the site.

x = read_html("https://ca.investing.com/economic-calendar/nonfarm-payrolls-227")%>%
  html_nodes('table')%>%.[1]%>%html_table(fill = T)

print(x)
# Release Date  Time Actual Forecast Previous   
1 May 03, 2019  (Apr) 08:30   263K     181K     189K NA
2 Apr 05, 2019  (Mar) 08:30   196K     175K      33K NA
3 Mar 08, 2019  (Feb) 09:30    20K     181K     311K NA
4 Feb 01, 2019  (Jan) 09:30   304K     165K     222K NA
5 Jan 04, 2019  (Dec) 09:30   312K     178K     176K NA
6 Dec 07, 2018  (Nov) 09:30   155K     200K     237K NA

0 Answers