Created
June 4, 2013 14:25
-
-
Save yanping/5706328 to your computer and use it in GitHub Desktop.
获取第6界R语言会议报名者的区域分布信息
This file contains hidden or 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
url <- "http://www.vasee.com/event/manage/echart_data.jsp?id=ff8080813d7c8a71013d87e56a9b47b0&type=5&date=1×tamp=11.57071830239147" | |
library(XML) | |
xmlResult <- xmlTreeParse(url) | |
doc <- xmlParse(url) | |
prov <- xpathSApply(doc,path='//area[@title]', xmlGetAttr, "title") | |
reg <- regexpr("[1-9]+", prov) | |
ret <- substring(prov,reg, reg + attr(reg,'match.length')-1) | |
ret <- ifelse(grepl("无", prov),0,ret) | |
num <- as.numeric(ret) | |
reg2 <- regexpr("[1-9]", prov) + regexpr("无", prov) | |
name <- substring(prov, 1, reg2) | |
attend <- data.frame(name,num) | |
attend <- na.omit(attend) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment