res <- WikipediR::page_info("en", "wikipedia",
page = "Category:Lakes of Michigan")
Scrape lake names
res <- xml2::read_html(res$query$pages[[1]]$canonicalurl)
res <- rvest::html_nodes(res, "#mw-pages .mw-category")
res <- rvest::html_nodes(res, "li")
res <- rvest::html_nodes(res, "a")
res <- rvest::html_attr(res, "title")
Remove junk names
res <- res[!(seq_len(length(res)) %in% grep("List", res))]
res <- res[!(seq_len(length(res)) %in% grep("Watershed", res))]
res <- res[!(seq_len(length(res)) %in% grep("lakes", res))]
res <- res[!(seq_len(length(res)) %in% grep("Mud Lake", res))]
Scrape tables
res <- lapply(res, lake_wiki)
# remove missing coordinates
res <- res[unlist(lapply(res, function(x) !is.na(x[, "Lat"])))]