[R] 404 HTTP not found

Stefan Th. Gries stgries_lists at arcor.de
Mon Sep 18 06:15:31 CEST 2006


Hi

I wrote a script which retrieves links from websites and loads them with scan:

...
website<-tolower(scan(current.pages[i], what="character", sep="\n", quiet=TRUE))
...

However occasionally, the script finds broken links, such as <http://www.google.com/test>. when the script tries to access such websites, the repeat loop breaks and I get the error message

Error in file(file, "r") : unable to open connection
In addition: Warning message:
cannot open: HTTP status was '404 Not Found' 

Now my question: is there a way to test whether the target of a link exists that does not result in an error and, thus, discontinues my loop? I looked at the help files for files, scans, connections, and did a search for "404?' in th archives but couldn't find anything. I work with R 2.3.1 patched on Windows XP (both Home and Prof) and would appreciate any pointers ...
Thanks a lot,
STG



More information about the R-help mailing list