Created
May 13, 2014 17:55
-
-
Save hadley/bfcf043981f34a6f2309 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(httr) | |
library(XML) | |
library(selectr) | |
xpath <- function(x) structure(x, class = "xpath") | |
sel <- function(x) xpath(css_to_xpath(x, prefix = "//")) | |
url <- "http://www.boxofficemojo.com/movies/?id=ateam.htm" | |
html <- content(GET(url), "parsed") | |
"[.HTMLInternalDocument" <- function(x, i, ...) { | |
if (inherits(i, "xpath")) { | |
xpathApply(x, i) | |
} else { | |
NextMethod() | |
} | |
} | |
html[sel("center")] | |
html[sel("center font")] | |
html[sel("center font b")] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment