R/cran_mirror.R

##-------------------------------------------------------------
## 
##-------------------------------------------------------------
cran_mirror = function(url = "https://cran.r-project.org/mirrors.html")
{
#	internet = curl::nslookup("www.r-project.org", ipv4_only = TRUE, error = FALSE)
#	
#	if(is.null(internet))
#	{
#		mensagem(msg = 6, aviso="Conection", subtitulo = "Sem acesso a internet")		
#		return(NULL)
#	}#end if
	
	txt = readLines(url)
	idx = grep("http:|https:", txt)
	a = txt[idx]
	t1 = gsub(".*href=", "", a)
	t2 = gsub(" target=.*", "", t1)
	t3 = gsub('\\"', "", t2)
	
	a1 = grep("[A-Z]", txt[-idx], value = T)
	a2 = grep("<", a1)
	a3 = a1[-a2]
	a4 = a3[-c(1:3)]
	
	cran = data.frame(URL = t3, Institution = a4, stringsAsFactors = FALSE)
	
	return(cran)
}#end function cran_mirror
salah31416/bibliotheca documentation built on June 16, 2019, 10:02 p.m.