File: checkLinks.R

package info (click to toggle)
r-cran-xml 3.98-1.5-1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 9,464 kB
  • ctags: 636
  • sloc: xml: 79,579; ansic: 6,518; asm: 644; sh: 16; makefile: 1
file content (13 lines) | stat: -rw-r--r-- 318 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
checkLinks =
function(doc, local = TRUE)
{
  doc = htmlParse(doc)
  links = sapply(getNodeSet(doc, "//a[@href]"), xmlGetAttr, "href")
  if(local)
    links = grep("^(http|mailto)", links, invert = TRUE, value = TRUE)

  cur = getwd()
  on.exit(setwd(cur))
  setwd( dirname(docName(doc)))
  links[!file.exists(links)]
}