great, exactly what I've being looking for ! thanks a lot ! 2010/12/13 Duncan Murdoch <murdoch.dun...@gmail.com>
> On 13/12/2010 12:56 PM, Arthur Charpentier wrote: > >> sorry... localization is a string of characters >> for instance >> localization = >> paste("http://www.resultsfromtennis.com/ >> ",year,"/atp/",city,".html",sep="") >> where year is 2006 and city can be "wimbledon" >> hence here, since the page >> "http://www.resultsfromtennis.com/2007/atp/wimbledon.html" does exist, I >> can get the tables inside >> but >> "http://www.resultsfromtennis.com/1977/atp/shertogenbosch.html" >> does not exist... is there a way to detect that the html page does not >> exist ? >> > > If you try to read it and get an error, you will know there's a problem. > For example, > > x <- "http://cran.r-project.ogr" # has a typo > con <- url(x) > html <- readLines(con) > > This should produce an error, but might give you a junk page if your DNS > provider substitutes for it. You can catch the error using > > html <- try(readLines(con), silent=TRUE) > if (inherits(html, "try-error")) cat("Error!") > > Duncan Murdoch > > >> >> 2010/12/13 Duncan Murdoch <murdoch.dun...@gmail.com >> <mailto:murdoch.dun...@gmail.com>> >> >> >> On 13/12/2010 12:36 PM, Arthur Charpentier wrote: >> >> I was wondering if there was a function like "does connection >> exists" ? >> >> >> See ?showConnections. >> >> >> I am currently using loops to build up a database, and I have >> either >> >> B = getConnection(localization) >> >> Error in getConnection(localization) : there is no connection >> -2147483648 >> In addition: Warning message: >> In getConnection(localization) : NAs introduced by coercion >> >> >> Where did the localization variable come from? getConnection is >> pretty rarely used. >> >> >> >> or >> >> B = scan(localization) >> >> Error in file(file, "r") : cannot open the connection >> In addition: Warning message: >> In file(file, "r") : cannot open: HTTP status was '404 Not Found' >> >> is there a way to test where localization is an html page, or >> not ? and to >> say that if localization does exist, then scan it ? >> >> >> What's your definition of an html page? Testing for valid html is >> hard. >> >> Duncan Murdoch >> >> >> > [[alternative HTML version deleted]] ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel