Massimo Caliman
by Massimo Caliman
~1 min read

Categories

  • R

Tags

  • code
  • data-analysis
  • en
  • r

The script in question is straightforward but demonstrates the convenience of using R when it comes to manipulating data and creating scripts or prototypes. It downloads the two droptime files from the NIC and checks whether they contain the domain of interest. The updated script is available on github https://github.com/mcaliman/R-utilities

# droptime_file_observer.R
# the format of droptime file is yyyymmdd09 and yyyymmdd16 
date <- Sys.Date()
filename1 <- paste0(format(date,format='%Y%m%d'),'09','.txt')
filename2 <- paste0(format(date,format='%Y%m%d'),'16','.txt')
url1<-paste0('http://www.nic.it/droptime/files/',filename1)
url2<-paste0('http://www.nic.it/droptime/files/',filename2)
download.file(url1,filename1)
download.file(url2,filename2)

droptime_file1<-readLines(filename1)
droptime_file2<-readLines(filename2)
domain_to_find <- 'dominiochemiinteressa.it'
if (is.element(domain_to_find, droptime_file1)){
	print('present in droptime file!');
}
if (is.element(domain_to_find, droptime_file2)){
	print('present in droptime file!');
}

We can customize it by emailing instead of printing and then scheduling everything with cron.