I have been using the itunesr
package to scrape reviews from the app store and was wondering if anyone could help me create a loop that would scrape all the pages iteratively, rather than doing it page by page as I have been
XX_reviews1 <- getReviews(123456789,'us',1)
XX_reviews2 <- getReviews(123456789,'us',2)
XX_reviews3 <- getReviews(123456789,'us',3)
XX_reviews4 <- getReviews(123456789,'us',4)
fb_reviews <- rbind(fb_reviews1,fb_reviews2,fb_reviews3,fb_reviews4)
Any help on this would be greatly appreciated.
I don't know anything about the itunesr
package, but generally you can use the lapply
function to apply a function for/to multiple inputs. The general setup is something this:
results <- lapply(inputs, function(n) {...})
where at the dots you do something with n. And in your case you want to then combine it to a data.frame
, which can be done for list with the dplyr
package:
install.packages('dplyr') # If you don't have it yet
library(dplyr)
dplyr::rbind_list(lapply(1:4, function(n) {getReviews(123456789,'us',n)}))