collect_all.Rmd
⚠️ The number of results you will be able to return will be dependent on your level of access:
In the introduction we showcased how to do a quick search. But it is very likely that you will need to collect more than 10 results. How would this task be performed?
Firstly, load purrr
and dplyr
:
Once you have the packages loaded, next set up the iterator by firstly getting the number of hits in the database:
query <- "crocodile shoot +hunting -shoes"
total_hits <- query_hits(query)
iterator <- seq(0, total_hits, by = 10)
You can now iterate over the search in the database. In this example I only show 10 as in the case of over query, we have to query 700 request to bring back ALL the information:
out <- iterator[1:5] %>% map_dfr(., ~query_text(query, from_pos = .x))
Finally, we can use the same itterator idea to collect the meta information for all the pages: