Skip to content

Instantly share code, notes, and snippets.

@portableant
Created September 26, 2018 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save portableant/5d170db8514687663f1a28718ec9f1c2 to your computer and use it in GitHub Desktop.
Save portableant/5d170db8514687663f1a28718ec9f1c2 to your computer and use it in GitHub Desktop.
Get coin data for Steph
library(jsonlite)
url <- 'https://finds.org.uk/database/search/results/q/objectType:COIN+-institution%3AIARCW+-institution:CCI/createdBefore/2017-11-12/format/json'
json <- fromJSON(url)
total <- json$meta$totalResults
results <- json$meta$resultsPerPage
pagination <- ceiling(total/results)
keeps <- c("id","old_findID","broadperiod", "objectType", "institution", "creator", "fourFigureLat", "fourFigureLon")
data <- json$results
data <- data[,(names(data) %in% keeps)]
for (i in seq(from=2, to=pagination, by=1)){
urlDownload <- paste(url, '/page/', i, sep='')
pagedJson <- fromJSON(urlDownload)
records <- pagedJson$results
records <- records[,(names(records) %in% keeps)]
data <-rbind(data,records)
}
write.csv(data, file='inscribedSealMatrices.csv',row.names=FALSE, na="")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment