Last active
December 13, 2015 13:00
-
-
Save andreasio/42633576d6d0daf3e5b5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(httr) | |
# example | |
cvrnumbers <- c('10112354', '57471719', '82675418') | |
cvr2name <- function(cvrnumbers, useragent="mit projekt") { | |
# this gets company data from cvrapi.dk - its important to specify your project in useragent. | |
# Its easy to get banned if you don't | |
require(httr) | |
results <- vector(length=length(cvrnumbers)) | |
for (i in 1:length(cvrnumbers)) { | |
cvrvalue <- cvrnumbers[i] | |
url=paste0('http://cvrapi.dk/api?search=', cvrvalue, "&country=dk") | |
results[i]<- paste(httr::content(httr::GET(url=url, httr::add_headers("user-agent"=useragent)))[2]) | |
} | |
return(results) | |
} | |
cvr2name(cvrnumbers) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment